From 74a1061b6156576364ae6c60898ac5418a0ca4dd Mon Sep 17 00:00:00 2001 From: WilliamAntonRohm Date: Fri, 20 Sep 2019 10:32:54 -0700 Subject: [PATCH 01/10] updating for Try .NET --- xml/System/Random.xml | 46 ++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/xml/System/Random.xml b/xml/System/Random.xml index 1bed639abd0..ad119f6cf2d 100644 --- a/xml/System/Random.xml +++ b/xml/System/Random.xml @@ -38,7 +38,7 @@ - Represents a pseudo-random number generator, which is a device that produces a sequence of numbers that meet certain statistical requirements for randomness. + Represents a pseudo-random number generator, which is an algorithm that produces a sequence of numbers that meet certain statistical requirements for randomness. class or derive a class from . + [!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)] + In this topic: [Instantiating the random number generator](#Instantiate) @@ -79,7 +81,7 @@ To produce different sequences of random numbers, you can make the seed value time-dependent, thereby producing a different series with each new instance of . The parameterized constructor can take an value based on the number of ticks in the current time, whereas the parameterless constructor uses the system clock to generate its seed value. However, on the .NET Framework only, because the clock has finite resolution, using the parameterless constructor to create different objects in close succession creates random number generators that produce identical sequences of random numbers. The following example illustrates how two objects that are instantiated in close succession in a .NET Framework application generate an identical series of random numbers. On most Windows systems, objects created within 15 milliseconds of one another are likely to have identical seed values. [!code-cpp[System.Random#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/random1.cpp#1)] - [!code-csharp[System.Random#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/Random1.cs#1)] + [!code-csharp-interactive[System.Random#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/Random1.cs#1)] [!code-vb[System.Random#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random/vb/Random1.vb#1)] To avoid this problem, create a single object instead of multiple objects. Note that the `Random` class in .NET Core does not have this limitation. @@ -134,7 +136,7 @@ To avoid this problem, create a single object instead of mu - A series of values. You determine the number of byte values by passing an array initialized to the number of elements you want the method to return to the method. The following example generates 20 bytes. [!code-cpp[System.Random#5](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/nextbytes1.cpp#5)] - [!code-csharp[System.Random#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/nextbytes1.cs#5)] + [!code-csharp-interactive[System.Random#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/nextbytes1.cs#5)] [!code-vb[System.Random#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random/vb/nextbytes1.vb#5)] - A single integer. You can choose whether you want an integer from 0 to a maximum value ( - 1) by calling the method, an integer between 0 and a specific value by calling the method, or an integer within a range of values by calling the method. In the parameterized overloads, the specified maximum value is exclusive; that is, the actual maximum number generated is one less than the specified value. @@ -142,13 +144,13 @@ To avoid this problem, create a single object instead of mu The following example calls the method to generate 10 random numbers between -10 and 10. Note that the second argument to the method specifies the exclusive upper bound of the range of random values returned by the method. In other words, the largest integer that the method can return is one less than this value. [!code-cpp[System.Random#6](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/nextex1.cpp#6)] - [!code-csharp[System.Random#6](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/nextex1.cs#6)] + [!code-csharp-interactive[System.Random#6](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/nextex1.cs#6)] [!code-vb[System.Random#6](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random/vb/nextex1.vb#6)] - A single floating-point value from 0.0 to less than 1.0 by calling the method. The exclusive upper bound of the random number returned by the method is 1, so its actual upper bound is 0.99999999999999978. The following example generates 10 random floating-point numbers. [!code-cpp[System.Random#7](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/nextdoubleex1.cpp#7)] - [!code-csharp[System.Random#7](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/nextdoubleex1.cs#7)] + [!code-csharp-interactive[System.Random#7](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/nextdoubleex1.cs#7)] [!code-vb[System.Random#7](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random/vb/nextdoubleex1.vb#7)] > [!IMPORTANT] @@ -211,13 +213,13 @@ To avoid this problem, create a single object instead of mu If the interval between the minimum and maximum desired values is 1, you can add the difference between the desired starting interval and 0 to the number returned by the method. The following example does this to generate 10 random numbers between -1 and 0. [!code-cpp[System.Random#17](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/doublerange2.cpp#17)] - [!code-csharp[System.Random#17](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/doublerange2.cs#17)] + [!code-csharp-interactive[System.Random#17](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/doublerange2.cs#17)] [!code-vb[System.Random#17](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random/vb/doublerange2.vb#17)] To generate random floating-point numbers whose lower bound is 0 but upper bound is greater than 1 (or, in the case of negative numbers, whose lower bound is less than -1 and upper bound is 0), multiply the random number by the non-zero bound. The following example does this to generate 20 million random floating-point numbers that range from 0 to . In also displays the distribution of the random values generated by the method. [!code-cpp[System.Random#18](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/doublerange1.cpp#18)] - [!code-csharp[System.Random#18](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/doublerange1.cs#18)] + [!code-csharp-interactive[System.Random#18](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/doublerange1.cs#18)] [!code-vb[System.Random#18](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random/vb/doublerange1.vb#18)] To generate random floating-point numbers between two arbitrary values, like the method does for integers, use the following formula: @@ -229,7 +231,7 @@ Random.NextDouble() * (maxValue - minValue) + minValue The following example generates 1 million random numbers that range from 10.0 to 11.0, and displays their distribution. [!code-cpp[System.Random#19](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/doublerange3.cpp#19)] - [!code-csharp[System.Random#19](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/doublerange3.cs#19)] + [!code-csharp-interactive[System.Random#19](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/doublerange3.cs#19)] [!code-vb[System.Random#19](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random/vb/doublerange3.vb#19)] @@ -257,7 +259,7 @@ Random.NextDouble() * (maxValue - minValue) + minValue The following example uses this technique to generate 20 million random long integers and categorizes them in 10 equal groups. It then evaluates the distribution of the random numbers by counting the number in each group from 0 to . As the output from the example shows, the numbers are distributed more or less equally through the range of a long integer. [!code-cpp[System.Random#14](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/long1.cpp#14)] - [!code-csharp[System.Random#14](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/long1.cs#14)] + [!code-csharp-interactive[System.Random#14](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/long1.cs#14)] [!code-vb[System.Random#14](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random/vb/long1.vb#14)] An alternative technique that uses bit manipulation does not generate truly random numbers. This technique calls to generate two integers, left-shifts one by 32 bits, and ORs them together. This technique has two limitations: @@ -281,7 +283,7 @@ Random.NextDouble() * (maxValue - minValue) + minValue Random numbers often serve as indexes to retrieve values from arrays or collections. To retrieve a random index value, you can call the method, and use the lower bound of the array as the value of its `minValue` argument and one greater than the upper bound of the array as the value of its `maxValue` argument. For a zero-based array, this is equivalent to its property, or one greater than the value returned by the method. The following example randomly retrieves the name of a city in the United States from an array of cities. [!code-cpp[System.Random#10](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/array1.cpp#10)] - [!code-csharp[System.Random#10](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/array1.cs#10)] + [!code-csharp-interactive[System.Random#10](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/array1.cs#10)] [!code-vb[System.Random#10](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random/vb/array1.vb#10)] @@ -304,13 +306,13 @@ Random.NextDouble() * (maxValue - minValue) + minValue The following example creates a single random number generator and calls its , , and methods to generate sequences of random numbers within different ranges. [!code-cpp[System.Random#2](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/random2.cpp#2)] - [!code-csharp[System.Random#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/Random2.cs#2)] + [!code-csharp-interactive[System.Random#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/Random2.cs#2)] [!code-vb[System.Random#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random/vb/Random2.vb#2)] The following example generates a random integer that it uses as an index to retrieve a string value from an array. [!code-cpp[System.Random.Next#3](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next1.cpp#3)] - [!code-csharp[System.Random.Next#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Next/CS/next1.cs#3)] + [!code-csharp-interactive[System.Random.Next#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Next/CS/next1.cs#3)] [!code-vb[System.Random.Next#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next1.vb#3)] ]]> @@ -384,7 +386,7 @@ The default seed value is derived from the system clock, which has finite resolu The following example uses the parameterless constructor to instantiate three objects and displays a sequence of five random integers for each. If it is run on .NET Framework, because the first two objects are created in close succession, they are instantiated using identical seed values based on the system clock and, therefore, they produce an identical sequence of random numbers. On the other hand, the parameterless constructor of the third object is called after a two-second delay caused by calling the method. Because this produces a different seed value for the third object, it produces a different sequence of random numbers. - [!code-csharp[System.Random.Ctor#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor1.cs#2)] + [!code-csharp-interactive[System.Random.Ctor#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor1.cs#2)] [!code-vb[System.Random.Ctor#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Ctor/VB/ctor1.vb#2)] ]]> @@ -433,7 +435,7 @@ The following example uses the parameterless constructor to instantiate three overload does. However, the system clock might not have sufficient resolution to provide different invocations of this constructor with a different seed value. On the .NET Framework, this results in random number generators that generate identical sequences of pseudo-random numbers, as illustrated by the first two objects in the following example. To prevent this, apply an algorithm to differentiate the seed value in each invocation, or call the method to ensure that you provide each constructor with a different seed value. - [!code-csharp[System.Random.Ctor#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor4.cs#4)] + [!code-csharp-interactive[System.Random.Ctor#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor4.cs#4)] [!code-vb[System.Random.Ctor#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Ctor/VB/ctor4.vb#4)] Another option is to instantiate a single object that you use to generate all the random numbers in your application. This yields slightly better performance, since instantiating a random number generator is fairly expensive. @@ -444,7 +446,7 @@ The following example uses the parameterless constructor to instantiate three objects with the class constructor that takes a seed parameter and generates a sequence of random integers and doubles. The example illustrates that the same sequence is generated when the object is created again with the constructor and seed parameter. [!code-cpp[System.Random.Ctor#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Ctor/CPP/ctor.cpp#1)] - [!code-csharp[System.Random.Ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor.cs#1)] + [!code-csharp-interactive[System.Random.Ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor.cs#1)] [!code-vb[System.Random.Ctor#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Ctor/VB/ctor.vb#1)] ]]> @@ -582,13 +584,13 @@ The following example uses the parameterless constructor to instantiate three method. [!code-cpp[System.Random.Next#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next.cpp#1)] - [!code-csharp[System.Random.Next#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Next/CS/next.cs#1)] + [!code-csharp-interactive[System.Random.Next#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Next/CS/next.cs#1)] [!code-vb[System.Random.Next#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next.vb#1)] The following example generates a random integer that it uses as an index to retrieve a string value from an array. Because the highest index of the array is one less than its length, the value of the property is supplied as a the `maxValue` parameter. [!code-cpp[System.Random.Next#3](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next1.cpp#3)] - [!code-csharp[System.Random.Next#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Next/CS/next1.cs#3)] + [!code-csharp-interactive[System.Random.Next#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Next/CS/next1.cs#3)] [!code-vb[System.Random.Next#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next1.vb#3)] ]]> @@ -652,13 +654,13 @@ The following example uses the parameterless constructor to instantiate three method to generate random integers with three distinct ranges. Note that the exact output from the example depends on the system-supplied seed value passed to the class constructor. [!code-cpp[System.Random.Next#2](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next2.cpp#2)] - [!code-csharp[System.Random.Next#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Next/CS/Next2.cs#2)] + [!code-csharp-interactive[System.Random.Next#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Next/CS/Next2.cs#2)] [!code-vb[System.Random.Next#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next2.vb#2)] The following example generates a random integer that it uses as an index to retrieve a string value from an array. Because the highest index of the array is one less than its length, the value of the property is supplied as a the `maxValue` parameter. [!code-cpp[System.Random.Next#4](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next4.cpp#4)] - [!code-csharp[System.Random.Next#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Next/CS/next4.cs#4)] + [!code-csharp-interactive[System.Random.Next#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Next/CS/next4.cs#4)] [!code-vb[System.Random.Next#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next4.vb#4)] ]]> @@ -722,7 +724,7 @@ The following example uses the parameterless constructor to instantiate three method to fill an array of bytes with random byte values. [!code-cpp[Classic Random.NextBytes Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/CPP/source.cpp#1)] - [!code-csharp[Classic Random.NextBytes Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/CS/source.cs#1)] + [!code-csharp-interactive[Classic Random.NextBytes Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/CS/source.cs#1)] [!code-vb[Classic Random.NextBytes Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/VB/source.vb#1)] ]]> @@ -822,12 +824,12 @@ The following example uses the parameterless constructor to instantiate three method to generate sequences of random doubles. [!code-cpp[System.Random.Ctor#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Ctor/CPP/ctor.cpp#1)] - [!code-csharp[System.Random.Ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor.cs#1)] + [!code-csharp-interactive[System.Random.Ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor.cs#1)] [!code-vb[System.Random.Ctor#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Ctor/VB/ctor.vb#1)] The following example calls the method to generate 100 random numbers and displays their frequency distribution. - [!code-csharp[System.Random.NextDouble#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.random.nextdouble/cs/nextdouble1.cs#2)] + [!code-csharp-interactive[System.Random.NextDouble#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.random.nextdouble/cs/nextdouble1.cs#2)] [!code-vb[System.Random.NextDouble#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.random.nextdouble/vb/nextdouble1.vb#2)] ]]> From 761b007d701ac0574a6c28c0fe81db460fb2a46f Mon Sep 17 00:00:00 2001 From: WilliamAntonRohm Date: Tue, 24 Sep 2019 11:27:16 -0700 Subject: [PATCH 02/10] backing out Try .NET changes for 4 instances of 3 samples --- xml/System/Random.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xml/System/Random.xml b/xml/System/Random.xml index ad119f6cf2d..201013be05c 100644 --- a/xml/System/Random.xml +++ b/xml/System/Random.xml @@ -386,7 +386,7 @@ The default seed value is derived from the system clock, which has finite resolu The following example uses the parameterless constructor to instantiate three objects and displays a sequence of five random integers for each. If it is run on .NET Framework, because the first two objects are created in close succession, they are instantiated using identical seed values based on the system clock and, therefore, they produce an identical sequence of random numbers. On the other hand, the parameterless constructor of the third object is called after a two-second delay caused by calling the method. Because this produces a different seed value for the third object, it produces a different sequence of random numbers. - [!code-csharp-interactive[System.Random.Ctor#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor1.cs#2)] + [!code-csharp[System.Random.Ctor#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor1.cs#2)] [!code-vb[System.Random.Ctor#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Ctor/VB/ctor1.vb#2)] ]]> @@ -435,7 +435,7 @@ The following example uses the parameterless constructor to instantiate three overload does. However, the system clock might not have sufficient resolution to provide different invocations of this constructor with a different seed value. On the .NET Framework, this results in random number generators that generate identical sequences of pseudo-random numbers, as illustrated by the first two objects in the following example. To prevent this, apply an algorithm to differentiate the seed value in each invocation, or call the method to ensure that you provide each constructor with a different seed value. - [!code-csharp-interactive[System.Random.Ctor#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor4.cs#4)] + [!code-csharp[System.Random.Ctor#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor4.cs#4)] [!code-vb[System.Random.Ctor#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Ctor/VB/ctor4.vb#4)] Another option is to instantiate a single object that you use to generate all the random numbers in your application. This yields slightly better performance, since instantiating a random number generator is fairly expensive. @@ -446,7 +446,7 @@ The following example uses the parameterless constructor to instantiate three objects with the class constructor that takes a seed parameter and generates a sequence of random integers and doubles. The example illustrates that the same sequence is generated when the object is created again with the constructor and seed parameter. [!code-cpp[System.Random.Ctor#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Ctor/CPP/ctor.cpp#1)] - [!code-csharp-interactive[System.Random.Ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor.cs#1)] + [!code-csharp[System.Random.Ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor.cs#1)] [!code-vb[System.Random.Ctor#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Ctor/VB/ctor.vb#1)] ]]> @@ -824,7 +824,7 @@ The following example uses the parameterless constructor to instantiate three method to generate sequences of random doubles. [!code-cpp[System.Random.Ctor#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Ctor/CPP/ctor.cpp#1)] - [!code-csharp-interactive[System.Random.Ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor.cs#1)] + [!code-csharp[System.Random.Ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor.cs#1)] [!code-vb[System.Random.Ctor#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Ctor/VB/ctor.vb#1)] The following example calls the method to generate 100 random numbers and displays their frequency distribution. From 42db4a52d100350d690a9b99efd7392941a993cc Mon Sep 17 00:00:00 2001 From: William Anton Rohm Date: Sun, 22 Dec 2019 20:23:56 -0800 Subject: [PATCH 03/10] add Note per https://github.com/dotnet/dotnet-api-docs/pull/3219#discussion_r358973532 --- xml/System/Random.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xml/System/Random.xml b/xml/System/Random.xml index 201013be05c..c34c598f7af 100644 --- a/xml/System/Random.xml +++ b/xml/System/Random.xml @@ -821,8 +821,11 @@ The following example uses the parameterless constructor to instantiate three method to generate sequences of random doubles. + [!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)] + [!code-cpp[System.Random.Ctor#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Ctor/CPP/ctor.cpp#1)] [!code-csharp[System.Random.Ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor.cs#1)] [!code-vb[System.Random.Ctor#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Ctor/VB/ctor.vb#1)] From f101da063722f8134bd43bafdb5e3b71701f96d5 Mon Sep 17 00:00:00 2001 From: William Anton Rohm Date: Fri, 27 Dec 2019 16:03:40 -0800 Subject: [PATCH 04/10] addressing review comments --- xml/System/Random.xml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/xml/System/Random.xml b/xml/System/Random.xml index c34c598f7af..5a5602c8737 100644 --- a/xml/System/Random.xml +++ b/xml/System/Random.xml @@ -47,8 +47,6 @@ To generate a cryptographically secure random number, such as one that's suitable for creating a random password, use the class or derive a class from . - [!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)] - In this topic: [Instantiating the random number generator](#Instantiate) @@ -305,6 +303,8 @@ Random.NextDouble() * (maxValue - minValue) + minValue ## Examples The following example creates a single random number generator and calls its , , and methods to generate sequences of random numbers within different ranges. + [!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)] + [!code-cpp[System.Random#2](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/random2.cpp#2)] [!code-csharp-interactive[System.Random#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/Random2.cs#2)] [!code-vb[System.Random#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random/vb/Random2.vb#2)] @@ -463,6 +463,13 @@ The following example uses the parameterless constructor to instantiate three Returns a random integer. + + + @@ -582,7 +589,7 @@ The following example uses the parameterless constructor to instantiate three method. - + [!code-cpp[System.Random.Next#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next.cpp#1)] [!code-csharp-interactive[System.Random.Next#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Next/CS/next.cs#1)] [!code-vb[System.Random.Next#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next.vb#1)] From db3c4f9e88d0dd31b015459b80b48c995f835d36 Mon Sep 17 00:00:00 2001 From: William Anton Rohm Date: Fri, 27 Dec 2019 16:12:26 -0800 Subject: [PATCH 05/10] addressing last review comment --- xml/System/Random.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xml/System/Random.xml b/xml/System/Random.xml index 5a5602c8737..9415c630eb3 100644 --- a/xml/System/Random.xml +++ b/xml/System/Random.xml @@ -680,7 +680,7 @@ The following example uses the parameterless constructor to instantiate three - + @@ -729,7 +729,9 @@ The following example uses the parameterless constructor to instantiate three method to fill an array of bytes with random byte values. - + + [!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)] + [!code-cpp[Classic Random.NextBytes Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/CPP/source.cpp#1)] [!code-csharp-interactive[Classic Random.NextBytes Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/CS/source.cs#1)] [!code-vb[Classic Random.NextBytes Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/VB/source.vb#1)] @@ -743,7 +745,7 @@ The following example uses the parameterless constructor to instantiate three - + From 8d68641c0199e664e49d5ba64d3aa13b3a4a403b Mon Sep 17 00:00:00 2001 From: William Anton Rohm Date: Sun, 29 Dec 2019 16:10:39 -0800 Subject: [PATCH 06/10] moved interactive NOTEs up under heading --- xml/System/Random.xml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xml/System/Random.xml b/xml/System/Random.xml index 9415c630eb3..5296194b757 100644 --- a/xml/System/Random.xml +++ b/xml/System/Random.xml @@ -301,10 +301,11 @@ Random.NextDouble() * (maxValue - minValue) + minValue ## Examples - The following example creates a single random number generator and calls its , , and methods to generate sequences of random numbers within different ranges. - + [!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)] + The following example creates a single random number generator and calls its , , and methods to generate sequences of random numbers within different ranges. + [!code-cpp[System.Random#2](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/random2.cpp#2)] [!code-csharp-interactive[System.Random#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random/cs/Random2.cs#2)] [!code-vb[System.Random#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random/vb/Random2.vb#2)] @@ -728,10 +729,11 @@ The following example uses the parameterless constructor to instantiate three method to fill an array of bytes with random byte values. - + [!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)] + The following example demonstrates how to use the method to fill an array of bytes with random byte values. + [!code-cpp[Classic Random.NextBytes Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/CPP/source.cpp#1)] [!code-csharp-interactive[Classic Random.NextBytes Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/CS/source.cs#1)] [!code-vb[Classic Random.NextBytes Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/VB/source.vb#1)] @@ -831,10 +833,10 @@ The following example uses the parameterless constructor to instantiate three method to generate sequences of random doubles. - [!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)] + The following example uses the method to generate sequences of random doubles. + [!code-cpp[System.Random.Ctor#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Ctor/CPP/ctor.cpp#1)] [!code-csharp[System.Random.Ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Ctor/CS/ctor.cs#1)] [!code-vb[System.Random.Ctor#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Ctor/VB/ctor.vb#1)] From 17ed38441c46a3a853b6392cb9dcf63294489e99 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Wed, 8 Jan 2020 17:18:29 -0800 Subject: [PATCH 07/10] fix membergroup --- xml/System/Random.xml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/xml/System/Random.xml b/xml/System/Random.xml index 5296194b757..1cf54fdef9a 100644 --- a/xml/System/Random.xml +++ b/xml/System/Random.xml @@ -682,6 +682,27 @@ The following example uses the parameterless constructor to instantiate three + + System.Runtime.Extensions + 4.0.0.0 + 4.0.10.0 + 4.1.0.0 + 4.2.0.0 + + + To be added. + + + + + + @@ -728,9 +749,7 @@ The following example uses the parameterless constructor to instantiate three method to fill an array of bytes with random byte values. From 4279f2528057ec773c042d501d0b91069fe52b58 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Wed, 8 Jan 2020 17:19:56 -0800 Subject: [PATCH 08/10] fix assemblies list --- xml/System/Random.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xml/System/Random.xml b/xml/System/Random.xml index 1cf54fdef9a..5766e6b8652 100644 --- a/xml/System/Random.xml +++ b/xml/System/Random.xml @@ -688,6 +688,19 @@ The following example uses the parameterless constructor to instantiate three 4.0.10.0 4.1.0.0 4.2.0.0 + 4.2.1.0 + + + mscorlib + 1.0.5000.0 + 2.0.0.0 + 2.0.5.0 + 4.0.0.0 + + + netstandard + 2.0.0.0 + 2.1.0.0 To be added. From 0c3457e45bacb26d0387282c3ff187fc38d5cd8d Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Wed, 8 Jan 2020 17:20:48 -0800 Subject: [PATCH 09/10] fix closing tag --- xml/System/Random.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System/Random.xml b/xml/System/Random.xml index 5766e6b8652..e172595a190 100644 --- a/xml/System/Random.xml +++ b/xml/System/Random.xml @@ -779,7 +779,7 @@ The following example uses the parameterless constructor to instantiate three - + From 17e247b2c0cc5d01ccd96073e6a67647a35add28 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Fri, 10 Jan 2020 16:05:22 -0800 Subject: [PATCH 10/10] remove notes for try.net --- xml/System/Random.xml | 46 +------------------------------------------ 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/xml/System/Random.xml b/xml/System/Random.xml index e172595a190..4b0f91d3192 100644 --- a/xml/System/Random.xml +++ b/xml/System/Random.xml @@ -302,8 +302,6 @@ Random.NextDouble() * (maxValue - minValue) + minValue ## Examples - [!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)] - The following example creates a single random number generator and calls its , , and methods to generate sequences of random numbers within different ranges. [!code-cpp[System.Random#2](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/random2.cpp#2)] @@ -464,13 +462,7 @@ The following example uses the parameterless constructor to instantiate three Returns a random integer. - - - + To be added. @@ -681,40 +673,6 @@ The following example uses the parameterless constructor to instantiate three - - - System.Runtime.Extensions - 4.0.0.0 - 4.0.10.0 - 4.1.0.0 - 4.2.0.0 - 4.2.1.0 - - - mscorlib - 1.0.5000.0 - 2.0.0.0 - 2.0.5.0 - 4.0.0.0 - - - netstandard - 2.0.0.0 - 2.1.0.0 - - - To be added. - - - - - @@ -865,8 +823,6 @@ The following example uses the parameterless constructor to instantiate three method to generate sequences of random doubles. [!code-cpp[System.Random.Ctor#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Ctor/CPP/ctor.cpp#1)]