in .net how can we get random values.To get the random value we use the Random class.
mainly random selection is used in the Online Examination project for the random selection of the Questions so no two neighbour systems have same questions in same order.
take 1 button and 1 label..
on the button click event write the code....
make the object of random class.we call the Next()method of the random class.which contains the 3 overloaded method.
first method.
which return a non negative value...
output
when you click on the button you will get value.again you click on the button you will get another value.
second overloaded method-
it contains one argument max value.it will generate the random value which will less than the maximum value you will give in the argument
it will generate all random values below 500.
it will generate 296 and 179 which is less than 500.again you will get random value when you will click on the button.
Third overloaded method-
it contain 2 arguments min value and max value.this method generate random value with in the range .
output-
you will get random value between 20 and 50.
mainly random selection is used in the Online Examination project for the random selection of the Questions so no two neighbour systems have same questions in same order.
take 1 button and 1 label..
on the button click event write the code....
make the object of random class.we call the Next()method of the random class.which contains the 3 overloaded method.
first method.
which return a non negative value...
output
when you click on the button you will get value.again you click on the button you will get another value.
second overloaded method-
it contains one argument max value.it will generate the random value which will less than the maximum value you will give in the argument
it will generate all random values below 500.
it will generate 296 and 179 which is less than 500.again you will get random value when you will click on the button.
Third overloaded method-
it contain 2 arguments min value and max value.this method generate random value with in the range .
output-
you will get random value between 20 and 50.
No comments :
Post a Comment