From the course: Advanced C#: Functional Programming Patterns
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
A functional Random class - C# Tutorial
From the course: Advanced C#: Functional Programming Patterns
A functional Random class
The random generation code that I'm using in this chapter is in this RandomLib project in Visual Studio. There are three classes in this library. There's the generator class itself, which I've called Gen. There's some random extensions which we'll look at later in this chapter. And there is the RandomResult class, which contains the results that are returned from calling Next in the random generator. And I'm using that in this ConsoleApp up here. So I've got a reference to my project here, RandomLib project. And I'm calling the code. I'm setting up the code in examples and I'm calling it in program. So if I go look at examples, here's the different examples. So let's start by looking at the generator class itself. Let's start with line 6. That is the Next() method. This is the default random number generator for this class. It's going to take an int as a seed, and it's going to return a custom type called RandomResult of type int. And that's going to contain two values. Let me show…