1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
|
<Type Name="Random" FullName="System.Random" FullNameSP="System_Random" Maintainer="ecma">
<TypeSignature Language="ILASM" Value=".class public serializable Random extends System.Object" />
<TypeSignature Language="C#" Value="public class Random" />
<MemberOfLibrary>BCL</MemberOfLibrary>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyPublicKey>[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ]</AssemblyPublicKey>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
</AssemblyInfo>
<ThreadingSafetyStatement>All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.</ThreadingSafetyStatement>
<Docs>
<summary>
<para>Generates pseudo-random numbers.</para>
</summary>
<remarks>
<para> Instances of this class are initialized using a "seed",
or starting value. The series of numbers
generated by instances of the class are repeatable: given the
same seed value,
all instances of this class generate the same series of numbers.</para>
<para>
<block subset="none" type="note"> The numbers generated by this class are chosen with equal
probability from a finite set of numbers. The numbers are generated by a
definite mathematical algorithm and are therefore not truly random, but are
sufficiently random for practical purposes. For this reason, the numbers are
considered to be pseudo-random.
</block>
</para>
<example>
<code lang="C#">
Random random = new Random ();
// play heads or tails ten times with a fair coin
for (int i = 0; i < 10; ++i) {
if (random.NextDouble () < 0.5)
Console.WriteLine ("Head!");
else
Console.WriteLine ("Tails!");
}
</code>
</example>
</remarks>
</Docs>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Members>
<Member MemberName="NextBytes">
<MemberSignature Language="ILASM" Value=".method public hidebysig virtual void NextBytes(class System.Byte[] buffer)" />
<MemberSignature Language="C#" Value="public virtual void NextBytes (byte[] buffer);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="buffer" Type="System.Byte[]" />
</Parameters>
<Docs>
<summary>
<para>Populates the elements of a specified array of bytes with random numbers.</para>
</summary>
<param name="buffer">An array of bytes to be populated with random numbers.</param>
<exception cref="T:System.ArgumentNullException">
<paramref name="buffer" /> is a <see langword="null" /> reference.</exception>
<remarks>
<para>
<block subset="none" type="behaviors">Each element of the array of bytes is set to a random number greater than or
equal to zero, and less than or equal to <see cref="F:System.Byte.MaxValue" />.</block>
</para>
<para>
<block subset="none" type="overrides">Override this method to customize
the algorithm used to generate the return value.</block>
</para>
<para>
<block subset="none" type="usage">Use the
<see langword=" NextByte" /> method to populate a <see cref="T:System.Byte" />
array with random numbers.</block>
</para>
</remarks>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="NextDouble">
<MemberSignature Language="ILASM" Value=".method public hidebysig virtual float64 NextDouble()" />
<MemberSignature Language="C#" Value="public virtual double NextDouble ();" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Double</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>
<para>Returns a random number between 0.0 and 1.0.</para>
</summary>
<returns>
<para>A <see cref="T:System.Double" /> greater than or equal to 0.0, and less than 1.0.</para>
</returns>
<remarks>
<para>
<block subset="none" type="behaviors">As described
above.</block>
</para>
<para>
<block subset="none" type="usage">Use this method to generate a
pseudo-random number greater than or equal to zero, and less than
one.</block>
</para>
</remarks>
</Docs>
<Excluded>1</Excluded>
<ExcludedLibrary>ExtendedNumerics</ExcludedLibrary>
</Member>
<Member MemberName="Next">
<MemberSignature Language="ILASM" Value=".method public hidebysig virtual int32 Next(int32 maxValue)" />
<MemberSignature Language="C#" Value="public virtual int Next (int maxValue);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="maxValue" Type="System.Int32" />
</Parameters>
<Docs>
<summary>
<para>Returns a pseudo-random positive number less than the specified
maximum.</para>
</summary>
<param name="maxValue">The upper bound of the random number to be generated. <paramref name="maxValue" /> is required to be greater than or equal to zero.</param>
<returns>
<para>A <see cref="T:System.Int32" /> set to a pseudo-random value greater than or equal to zero
and less than <paramref name="maxValue" />. If <paramref name="maxValue" /> is zero, returns zero.</para>
</returns>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="maxValue" /> is less than zero.</exception>
<remarks>
<para>
<block subset="none" type="behaviors">As described
above.</block>
</para>
<para>
<block subset="none" type="overrides">Override this method to customize
the algorithm used to generate the return value.</block>
</para>
<para>
<block subset="none" type="usage">Use this method to generate a pseudo-random number
less than the specified maximum value.</block>
</para>
</remarks>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="Next">
<MemberSignature Language="ILASM" Value=".method public hidebysig virtual int32 Next(int32 minValue, int32 maxValue)" />
<MemberSignature Language="C#" Value="public virtual int Next (int minValue, int maxValue);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="minValue" Type="System.Int32" />
<Parameter Name="maxValue" Type="System.Int32" />
</Parameters>
<Docs>
<summary>
<para>Returns a pseudo-random number within a specified range.</para>
</summary>
<param name="minValue">The lower bound of the random number returned.</param>
<param name="maxValue">The upper bound of the random number returned.</param>
<returns>
<para>A pseudo-random number greater than or equal to <paramref name="minValue" /> and
less than <paramref name="maxValue" />. If <paramref name="minValue" /> and
<paramref name="maxValue " />are equal, this value
is returned.</para>
</returns>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="minValue" /> is greater than <paramref name="maxValue" />.</exception>
<remarks>
<para>
<block subset="none" type="behaviors">As described above.</block>
</para>
<para>
<block subset="none" type="overrides">Override this
method to customize the algorithm used to generate the return
value.</block>
</para>
<para>
<block subset="none" type="usage">Use this method to generate
pseudo-random numbers in a specified range.</block>
</para>
</remarks>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="Next">
<MemberSignature Language="ILASM" Value=".method public hidebysig virtual int32 Next()" />
<MemberSignature Language="C#" Value="public virtual int Next ();" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>
<para>Returns a pseudo-random number between 0 and <see cref="F:System.Int32.MaxValue" />.</para>
</summary>
<returns>
<para>A <see cref="T:System.Int32" /> greater than or equal to zero and less than
<see cref="F:System.Int32.MaxValue" />.</para>
</returns>
<remarks>
<para>
<block subset="none" type="behaviors">As described above.</block>
</para>
<para>
<block subset="none" type="overrides">Override this method to customize the algorithm used to generate the return value.</block>
</para>
</remarks>
<example>
<para>The following example demonstrates using the
<see langword="Next" /> method. The output generated by this example
will
vary.</para>
<code lang="C#">using System;
class RandomTest {
public static void Main() {
Random rand1 = new Random();
for (int i = 0; i<10;i++)
Console.WriteLine("The random number is {0}",rand1.Next());
}
}
</code>
<para>The output is</para>
<c>
<para> The random number is
1544196111</para>
<para> The random number is
181749919</para>
<para> The random number is
1045210087</para>
<para> The random number is
1073826097</para>
<para> The random number is
1533078806</para>
<para> The random number is
1083151645</para>
<para> The random number is
569083504</para>
<para> The random number is
1711370568</para>
<para> The random number is
578178313</para>
<para> The random number is
409444742</para>
</c>
</example>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="ILASM" Value="public rtspecialname specialname instance void .ctor()" />
<MemberSignature Language="C#" Value="public Random ();" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters />
<Docs>
<summary>
<para>Constructs a new instance of the
<see langword="Random" /> class using <see cref="P:System.Environment.TickCount" qualify="true" />
as the seed
value.</para>
</summary>
<remarks>
<para>This constructor is equivalent to <see cref="T:System.Random" />(<see cref="P:System.Environment.TickCount" /> ).</para>
<para>
<block subset="none" type="note">When generating
random numbers on high performance systems, the system clock value may not
produce the desired behavior. For details, see the <see cref="T:System.Random" />(<see cref="T:System.Int32" />
)
constructor.</block>
</para>
</remarks>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="ILASM" Value="public rtspecialname specialname instance void .ctor(int32 Seed)" />
<MemberSignature Language="C#" Value="public Random (int Seed);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="Seed" Type="System.Int32" />
</Parameters>
<Docs>
<summary>
<para>Constructs a new instance of the <see langword="Random" /> class using the specified
seed value.</para>
</summary>
<param name="Seed">A <see cref="T:System.Int32" /> used as the starting value for the pseudo-random number sequence.</param>
<remarks>
<para>
<block subset="none" type="note">To construct instances that produce different random number sequences, invoke
this constructor using different seed values such as may be
produced by the system clock. Note, however that on high performance systems, the system clock
may not change between invocations of the constructor, in which case the seed value
will be the same for different instances of <see langword="Random" /> . When this is the case, additional operations are required to have the seed values differ in each invocation.
</block>
</para>
</remarks>
<example>
<para> The following example demonstrates using a
bitwise complement operation to obtain different random numbers using a time-dependent
seed value on high performance systems.</para>
<code lang="C#">using System;
class RandomTest {
public static void Main() {
Random rand1 = new Random();
Random rand2 = new Random(Environment.TickCount);
Console.WriteLine("The random number is {0}",rand1.Next());
Console.WriteLine("The random number is {0}",rand2.Next());
Random rdm1 = new Random(unchecked(Environment.TickCount));
Random rdm2 = new Random(~unchecked(Environment.TickCount));
Console.WriteLine("The random number is {0}",rdm1.Next());
Console.WriteLine("The random number is {0}",rdm2.Next());
}
}
</code>
<c>
<para>The output is </para>
<para>The random number is 1990211954</para>
<para>The random number is 1990211954</para>
<para>The random number is 1990211954</para>
<para>The random number is 964628126</para>
</c>
</example>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="Sample">
<MemberSignature Language="C#" Value="protected virtual double Sample ();" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Double</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>To be added.</summary>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
<TypeExcluded>0</TypeExcluded>
</Type>
|