C # generates a random number

xiaoxiao2021-03-06  105

Private Void Page_Load (Object Sender, System.EventArgs E) {// Place user code here to initialize page // Initialize pseudo random number generator Random RO = new randem ((int) DateTime.now.ticks))) ;

// Method 1: Specifies the random number up and lower limit, generates random integers in the upper and lower limits String Roint = Ro.next (1, 20) .tostring (); Response.write ("Roint =" Roint
") ;

// Method 2: Returns the random integer String Roint2 = RO.NEXT (). ToString (); "ROINT2 =" ROINT2
");" ROINT2 = " ROINT2
");

// Method 3: Specify maximum non-negative random integers string Roint3 = ro.next (10) .tostring (); response.write ("Roint3 =" ROINT3 "
");

// Method 4: Generate random number between 0.0 and 1.0 string rodouble = RO.NEXTDOUBLE (). Tostring (); Response.write ("rodouble =" rodouble "
");

// Method 5: Use the random number Filled Specified byte array // byte arrays Each element of the array is set to // random number larger than or equal to zero and less than or equal to MaxValue // maxValue = 255 Byte [] b = new BYTE [5]; RO.NEXTBYTES (B); for (int i = 0; i <5; i ) {response.write ("Robytes" i "="); response.write (B [i] "
");} Compare Direct Direct Order by NewID ()

转载请注明原文地址:https://www.9cbs.com/read-101279.html

New Post(0)