Filter by Tags

How to generate a random int number using C#

Votes

1

1 0
This Question is relate to a Discussion :
Select a random number between two numbers using C#

What is the best way to generate a random integer number using C# ? Are there some inbuilt function which can be used for generating a random number between two numbers ?

Open E-School
Posted on : Sun, Jan 07, 2018
Views : 155
Comments

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Answers (3)


0
Loading...
Comments

Edit Answer

Submit

0
random rnd=newrandom();

int min,max;

public static int getrandom number (int min,int max)

{

return getrandom.next(min,max);

}

Jaspreet kaur
Thu, Jan 18, 2018
Loading...
Comments
Ravinder Singh :- The syntax for creating the object and the function is wrong. This code will not work. Also, C#, Java, C++, C and many other programming languages are case sensitive languages. We need to use the correct cases when writing code.
2018-01-18 8:52:00

Edit Answer

Submit

1

The easiest way to generate a random number in C# is to use the Random class defined in the System namespace. The Random class has a Next function which lets you generate a random number upto a max value or between a min value and a max value. For more information please read this article

 http://openeschool.com/tutorial/3177/csharp-tutorials-how-do-i-generate-a-random-int-number-in-csharp 

Ravinder Singh
Thu, Jan 18, 2018
Loading...
Comments

Edit Answer

Submit
This answer will permanently deleted. Do you really want to delete this Answer ?
To Add your Answer Please
LogIn | SignUp

Related Questions

Quick Links

E-Magazines

@

Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..

Ok

Login to Open ESchool OR Create your account    Login   SignUp