background preloader

C#

Facebook Twitter

Random.Next Method (Int32, Int32) (System) Returns a random integer that is within a specified range. public virtual int Next( int minValue, int maxValue ) Parameters minValue Type: System.Int32 The inclusive lower bound of the random number returned. maxValue The exclusive upper bound of the random number returned. maxValue must be greater than or equal to minValue.

Random.Next Method (Int32, Int32) (System)

Return Value Type: System.Int32A 32-bit signed integer greater than or equal to minValue and less than maxValue; that is, the range of return values includes minValue but not maxValue. Notes to Inheritors The following example generates a random integer that it uses as an index to retrieve a string value from an array. Task.Wait Method (Int32) (System.Threading.Tasks) Public bool Wait( int millisecondsTimeout ) Parameters millisecondsTimeout Type: System.Int32 Return Value .NET Framework Supported in: 4.5.1, 4.5, 4 .NET Framework Client Profile Supported in: 4 Portable Class Library Supported in: Portable Class Library .NET for Windows Store apps Supported in: Windows 8 .NET for Windows Phone apps Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1 Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

Task.Wait Method (Int32) (System.Threading.Tasks)

Generating Random Number and String in C# The Random class defined in the .NET Framework class library provides functionality to generate random numbers.

Generating Random Number and String in C#

The Random class constructors have two overloaded forms. It takes either no value or it takes a seed value. The Random class has three public methods - Next, NextBytes, and NextDouble. The Next method returns a random number, NextBytes returns an array of bytes filled with random numbers, and NextDouble returns a random number between 0.0 and 1.0. The Next method has three overloaded forms and allows you to set the minimum and maximum range of the random number. The following code returns a random number: int num = random.Next(); The following code returns a random number less than 1000. int num = random.Next(1000); The following code returns a random number between min and max:

Lambda Expressions (C# Programming Guide)