C# | Random.NextDouble() Method Last Updated : 01 May, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The NextDouble() Method of System.Random class in C# is used to return a random floating-point number which is greater than or equal to 0.0, and less than 1.0. Syntax: public virtual double NextDouble(); Return Value: This method returns a double-precision floating point number which is greater than or equal to 0.0, and less than 1.0. Below program illustrates the use of NextDouble() Method: Example 1: csharp // C# program to illustrate the // Random.NextDouble() Method using System; class GFG { // Driver code public static void Main() { // Instantiate random number generator Random rand = new Random(); // Print 10 random floating point numbers Console.WriteLine("Printing 10 random floating point numbers"); for (int i = 0; i < 10; i++) Console.WriteLine("{0} -> {1}", i, rand.NextDouble()); } } Output: Printing 10 random floating point numbers 0 -> 0.0227202852362396 1 -> 0.624568469647583 2 -> 0.0145442797870116 3 -> 0.646489209330869 4 -> 0.967497945748036 5 -> 0.839329582098559 6 -> 0.873648912121378 7 -> 0.16200648022909 8 -> 0.66018275761054 9 -> 0.0837694853934317 Example 2: csharp // C# program to illustrate the // Random.NextDouble() Method using System; class GFG { // Driver code public static void Main() { // Instantiate random number generator Random rand = new Random(); // Instantiate an array of double double[] a = new double[10]; // Store random floating point // numbers in the array for (int i = 0; i < 10; i++) a[i] = rand.NextDouble(); // Print 10 random floating point numbers Console.WriteLine("Printing 10 random "+ "floating point numbers"); for (int i = 0; i < 10; i++) Console.WriteLine("{0} -> {1}", i, a[i]); } } Output: Printing 10 random floating point numbers 0 -> 0.853536825558886 1 -> 0.741455778359182 2 -> 0.496043408986201 3 -> 0.0975164361752181 4 -> 0.120282317567748 5 -> 0.57163705703413 6 -> 0.749181974562435 7 -> 0.684014179596684 8 -> 0.691246760865323 9 -> 0.888019556127498 Reference: https://docs.microsoft.com/en-us/dotnet/api/system.random.nextdouble?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article C# | Random.NextDouble() Method R rupesh_rao Follow Improve Article Tags : C# CSharp-method CSharp-Random-Class Similar Reads C# | Random.Next() Method The Next() Method of System.Random class in C# is used to get a random integer number. This method can be overloaded by passing different parameters to it as follows: Next() Next(Int32) Next(Int32, Int32) Next() Method This method is used to returns a non-negative random integer. Syntax: public virt 3 min read C# | Random.NextBytes() Method The NextBytes(Byte[]) method of the System.Random class in C# is used to fill the elements of a specified array of bytes with random numbers. This method takes a byte array as a parameter and fills it with random numbers. Syntax: public virtual void NextBytes (byte[] buffer); Here, buffer is the arr 2 min read C# - Randomly Generating Strings In C#, a string is a sequence of Unicode characters or an array of characters. The range of Unicode characters will be U+0000 to U+FFFF. A string is the representation of the text. In this article, we will learn how to randomly generate strings and alphanumeric strings. So to do the task we use the 6 min read C# Program to Generate Random Even Numbers Using LINQ Parallel Query LINQ is known as Language Integrated Query and was introduced in .NET 3.5. It gives power to .NET languages to generate or create queries to retrieve data from the data source. In this article, we will generate random even numbers in parallel using LINQ. So, we will use ParallelQuery{TSource} to gen 2 min read rand() in C The rand() function in the C programming language is used to generate pseudo-random numbers. It is used in C to generate random numbers in the range 0 to RAND_MAX. The rand() function is part of the standard C library <stdlib.h> so to use this function, we need to include the <stdlib.h> 3 min read Like