diff --git a/xml/System.Collections.Generic/Dictionary`2.xml b/xml/System.Collections.Generic/Dictionary`2.xml index 2d3e418eea6..8655791122a 100644 --- a/xml/System.Collections.Generic/Dictionary`2.xml +++ b/xml/System.Collections.Generic/Dictionary`2.xml @@ -292,8 +292,8 @@ ## Examples The following code example shows how to use the constructor to initialize a with sorted content from another dictionary. The code example creates a and populates it with data in random order, then passes the to the constructor, creating a that is sorted. This is useful if you need to build a sorted dictionary that at some point becomes static; copying the data from a to a improves retrieval speed. - [!code-csharp[Generic.Dictionary.ctor_IDic#1](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary.ctor_IDic/CS/source.cs#1)] - [!code-vb[Generic.Dictionary.ctor_IDic#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary.ctor_IDic/VB/source.vb#1)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary.ctor_IDic/CS/source.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary.ctor_IDic/VB/source.vb" id="Snippet1"::: ]]> @@ -391,8 +391,8 @@ ## Examples The following code example creates a with a case-insensitive equality comparer for the current culture. The example adds four elements, some with lower-case keys and some with upper-case keys. The example then attempts to add an element with a key that differs from an existing key only by case, catches the resulting exception, and displays an error message. Finally, the example displays the elements in the dictionary. - [!code-csharp[Generic.Dictionary.ctor_IEqC#1](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary.ctor_IEqC/CS/source.cs#1)] - [!code-vb[Generic.Dictionary.ctor_IEqC#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary.ctor_IEqC/VB/source.vb#1)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary.ctor_IEqC/CS/source.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary.ctor_IEqC/VB/source.vb" id="Snippet1"::: ]]> @@ -454,8 +454,8 @@ ## Examples The following code example creates a dictionary with an initial capacity of 4 and populates it with 4 entries. - [!code-csharp[Generic.Dictionary.ctor_Int32#1](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary.ctor_Int32/CS/source.cs#1)] - [!code-vb[Generic.Dictionary.ctor_Int32#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary.ctor_Int32/VB/source.vb#1)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary.ctor_Int32/CS/source.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary.ctor_Int32/VB/source.vb" id="Snippet1"::: ]]> @@ -526,8 +526,8 @@ > [!NOTE] > When you create a new dictionary with a case-insensitive comparer and populate it with entries from a dictionary that uses a case-sensitive comparer, as in this example, an exception occurs if the input dictionary has keys that differ only by case. - [!code-csharp[Generic.Dictionary.ctor_IDicIEqC#1](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary.ctor_IDicIEqC/CS/source.cs#1)] - [!code-vb[Generic.Dictionary.ctor_IDicIEqC#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary.ctor_IDicIEqC/VB/source.vb#1)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary.ctor_IDicIEqC/CS/source.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary.ctor_IDicIEqC/VB/source.vb" id="Snippet1"::: ]]> @@ -631,8 +631,8 @@ ## Examples The following code example creates a with an initial capacity of 5 and a case-insensitive equality comparer for the current culture. The example adds four elements, some with lower-case keys and some with upper-case keys. The example then attempts to add an element with a key that differs from an existing key only by case, catches the resulting exception, and displays an error message. Finally, the example displays the elements in the dictionary. - [!code-csharp[Generic.Dictionary.ctor_Int32IEqC#1](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary.ctor_Int32IEqC/CS/source.cs#1)] - [!code-vb[Generic.Dictionary.ctor_Int32IEqC#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary.ctor_Int32IEqC/VB/source.vb#1)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary.ctor_Int32IEqC/CS/source.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary.ctor_Int32IEqC/VB/source.vb" id="Snippet1"::: ]]> diff --git a/xml/System.Collections.Generic/List`1.xml b/xml/System.Collections.Generic/List`1.xml index 2b1fe8c3dd0..9619ca3baf8 100644 --- a/xml/System.Collections.Generic/List`1.xml +++ b/xml/System.Collections.Generic/List`1.xml @@ -2996,6 +2996,18 @@ Public Function StartsWith(e As Employee) As Boolean Returns the zero-based index of the last occurrence of a value in the or in a portion of it. + + method. A of strings is created, with one entry that appears twice, at index location 0 and index location 5. The method overload searches the entire list from the end, and finds the second occurrence of the string. The method overload is used to search the list backward beginning with index location 3 and continuing to the beginning of the list, so it finds the first occurrence of the string in the list. Finally, the method overload is used to search a range of four entries, beginning at index location 4 and extending backward (that is, it searches the items at locations 4, 3, 2, and 1); this search returns -1 because there are no instances of the search string in that range. + + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/List`1_LastIndexOf/cpp/source.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/List`1_LastIndexOf/cs/source.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/List`1_LastIndexOf/vb/source.vb" id="Snippet1"::: + + ]]> + @@ -3046,15 +3058,6 @@ Public Function StartsWith(e As Employee) As Boolean This method performs a linear search; therefore, this method is an O(*n*) operation, where *n* is . - - -## Examples - The following example demonstrates all three overloads of the method. A of strings is created, with one entry that appears twice, at index location 0 and index location 5. The method overload searches the entire list from the end, and finds the second occurrence of the string. The method overload is used to search the list backward beginning with index location 3 and continuing to the beginning of the list, so it finds the first occurrence of the string in the list. Finally, the method overload is used to search a range of four entries, beginning at index location 4 and extending backward (that is, it searches the items at locations 4, 3, 2, and 1); this search returns -1 because there are no instances of the search string in that range. - - [!code-cpp[List\`1_LastIndexOf#1](~/samples/snippets/cpp/VS_Snippets_CLR/List`1_LastIndexOf/cpp/source.cpp#1)] - [!code-csharp[List\`1_LastIndexOf#1](~/samples/snippets/csharp/VS_Snippets_CLR/List`1_LastIndexOf/cs/source.cs#1)] - [!code-vb[List\`1_LastIndexOf#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/List`1_LastIndexOf/vb/source.vb#1)] - ]]> @@ -3111,16 +3114,7 @@ Public Function StartsWith(e As Employee) As Boolean This method determines equality using the default equality comparer for `T`, the type of values in the list. This method performs a linear search; therefore, this method is an O(*n*) operation, where *n* is the number of elements from the beginning of the to `index`. - - - -## Examples - The following example demonstrates all three overloads of the method. A of strings is created, with one entry that appears twice, at index location 0 and index location 5. The method overload searches the entire list from the end, and finds the second occurrence of the string. The method overload is used to search the list backward beginning with index location 3 and continuing to the beginning of the list, so it finds the first occurrence of the string in the list. Finally, the method overload is used to search a range of four entries, beginning at index location 4 and extending backward (that is, it searches the items at locations 4, 3, 2, and 1); this search returns -1 because there are no instances of the search string in that range. - - [!code-cpp[List\`1_LastIndexOf#1](~/samples/snippets/cpp/VS_Snippets_CLR/List`1_LastIndexOf/cpp/source.cpp#1)] - [!code-csharp[List\`1_LastIndexOf#1](~/samples/snippets/csharp/VS_Snippets_CLR/List`1_LastIndexOf/cs/source.cs#1)] - [!code-vb[List\`1_LastIndexOf#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/List`1_LastIndexOf/vb/source.vb#1)] - + ]]> @@ -3181,16 +3175,7 @@ Public Function StartsWith(e As Employee) As Boolean This method determines equality using the default equality comparer for `T`, the type of values in the list. This method performs a linear search; therefore, this method is an O(*n*) operation, where *n* is `count`. - - - -## Examples - The following example demonstrates all three overloads of the method. A of strings is created, with one entry that appears twice, at index location 0 and index location 5. The method overload searches the entire list from the end, and finds the second occurrence of the string. The method overload is used to search the list backward beginning with index location 3 and continuing to the beginning of the list, so it finds the first occurrence of the string in the list. Finally, the method overload is used to search a range of 4 entries, beginning at index location 4 and extending backward (that is, it searches the items at locations 4, 3, 2, and 1); this search returns -1 because there are no instances of the search string in that range. - - [!code-cpp[List\`1_LastIndexOf#1](~/samples/snippets/cpp/VS_Snippets_CLR/List`1_LastIndexOf/cpp/source.cpp#1)] - [!code-csharp[List\`1_LastIndexOf#1](~/samples/snippets/csharp/VS_Snippets_CLR/List`1_LastIndexOf/cs/source.cs#1)] - [!code-vb[List\`1_LastIndexOf#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/List`1_LastIndexOf/vb/source.vb#1)] - + ]]> diff --git a/xml/System.Collections.Generic/Queue`1.xml b/xml/System.Collections.Generic/Queue`1.xml index 1eaa2b34c92..809d0312a5c 100644 --- a/xml/System.Collections.Generic/Queue`1.xml +++ b/xml/System.Collections.Generic/Queue`1.xml @@ -123,6 +123,23 @@ Initializes a new instance of the class. + + generic class. The code example creates a queue of strings with default capacity and uses the method to queue five strings. The elements of the queue are enumerated, which does not change the state of the queue. The method is used to dequeue the first string. The method is used to look at the next item in the queue, and then the method is used to dequeue it. + + The method is used to create an array and copy the queue elements to it, then the array is passed to the constructor that takes , creating a copy of the queue. The elements of the copy are displayed. + + An array twice the size of the queue is created, and the method is used to copy the array elements beginning at the middle of the array. The constructor is used again to create a second copy of the queue containing three null elements at the beginning. + + The method is used to show that the string "four" is in the first copy of the queue, after which the method clears the copy and the property shows that the queue is empty. + + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Queue/cs/source.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Queue/vb/source.vb" id="Snippet1"::: + + ]]> + @@ -166,21 +183,7 @@ The capacity can be decreased by calling . This constructor is an O(1) operation. - - - -## Examples - The following code example demonstrates this constructor and several other methods of the generic class. The code example creates a queue of strings with default capacity and uses the method to queue five strings. The elements of the queue are enumerated, which does not change the state of the queue. The method is used to dequeue the first string. The method is used to look at the next item in the queue, and then the method is used to dequeue it. - - The method is used to create an array and copy the queue elements to it, then the array is passed to the constructor that takes , creating a copy of the queue. The elements of the copy are displayed. - - An array twice the size of the queue is created, and the method is used to copy the array elements beginning at the middle of the array. The constructor is used again to create a second copy of the queue containing three null elements at the beginning. - - The method is used to show that the string "four" is in the first copy of the queue, after which the method clears the copy and the property shows that the queue is empty. - - [!code-csharp[Generic.Queue#1](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Queue/cs/source.cs#1)] - [!code-vb[Generic.Queue#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Queue/vb/source.vb#1)] - + ]]> @@ -233,20 +236,6 @@ This constructor is an O(`n`) operation, where `n` is the number of elements in `collection`. - - -## Examples - The following code example demonstrates this constructor and several other methods of the generic class. The code example creates a queue of strings with default capacity and uses the method to queue five strings. The elements of the queue are enumerated, which does not change the state of the queue. The method is used to dequeue the first string. The method is used to look at the next item in the queue, and then the method is used to dequeue it. - - The method is used to create an array and copy the queue elements to it, then the array is passed to the constructor that takes , creating a copy of the queue. The elements of the copy are displayed. - - An array twice the size of the queue is created, and the method is used to copy the array elements beginning at the middle of the array. The constructor is used again to create a second copy of the queue containing three null elements at the beginning. - - The method is used to show that the string "four" is in the first copy of the queue, after which the method clears the copy and the property shows that the queue is empty. - - [!code-csharp[Generic.Queue#1](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Queue/cs/source.cs#1)] - [!code-vb[Generic.Queue#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Queue/vb/source.vb#1)] - ]]> diff --git a/xml/System/Enum.xml b/xml/System/Enum.xml index 327d25a3c62..d66e0324e17 100644 --- a/xml/System/Enum.xml +++ b/xml/System/Enum.xml @@ -150,8 +150,8 @@ When converting an integer to an enumeration value, it is possible to assign a value that is not actually a member of the enumeration. To prevent this, you can pass the integer to the method before performing the conversion. The following example uses this method to determine whether the elements in an array of integer values can be converted to `ArrivalStatus` values. - [!code-csharp[System.Enum.Class#7](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.enum.class/cs/classconversion1.cs#7)] - [!code-vb[System.Enum.Class#7](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.enum.class/vb/classconversion1.vb#7)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.enum.class/cs/classconversion1.cs" interactive="try-dotnet" id="Snippet7"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.enum.class/vb/classconversion1.vb" id="Snippet7"::: Although the class provides explicit interface implementations of the interface for converting from an enumeration value to an integral type, you should use the methods of the class, such as , to perform these conversions. The following example illustrates how you can use the method along with the method to convert an enumeration value to its underlying type. Note that this example does not require the underlying type of the enumeration to be known at compile time. @@ -233,17 +233,17 @@ In the following example, the `Grades` enumeration represents the possible letter grades that a student may receive in a class. An extension method named `Passing` is added to the `Grades` type so that each instance of that type now "knows" whether it represents a passing grade or not. The `Extensions` class also contains a static read-write variable that defines the minimum passing grade. The return value of the `Passing` extension method reflects the current value of that variable. - [!code-csharp[System.Enum.Class#18](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.enum.class/cs/Extensions.cs#18)] - [!code-vb[System.Enum.Class#18](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.enum.class/vb/Extensions.vb#18)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.enum.class/cs/Extensions.cs" interactive="try-dotnet" id="Snippet18"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.enum.class/vb/Extensions.vb" id="Snippet18"::: ## Examples The following example demonstrates using an enumeration to represent named values and another enumeration to represent named bit fields. - [!code-cpp[enummain#1](~/samples/snippets/cpp/VS_Snippets_CLR/enummain/CPP/EnumMain.cpp#1)] - [!code-csharp[enummain#1](~/samples/snippets/csharp/VS_Snippets_CLR/enummain/CS/EnumMain.cs#1)] - [!code-vb[enummain#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/enummain/VB/EnumMain.vb#1)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/enummain/CPP/EnumMain.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/enummain/CS/EnumMain.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/enummain/VB/EnumMain.vb" id="Snippet1"::: ]]> diff --git a/xml/System/Exception.xml b/xml/System/Exception.xml index 6626907c836..398fd799cdf 100644 --- a/xml/System/Exception.xml +++ b/xml/System/Exception.xml @@ -102,8 +102,8 @@ The exception that results when `obj` is `null` can be eliminated by modifying the source code to explicitly test for null before calling the override and then re-compiling. The following example contains the corrected source code that handles a `null` argument. - [!code-csharp[System.Exception.Class#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.exception.class/cs/usageerrors2.cs#5)] - [!code-vb[System.Exception.Class#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.exception.class/vb/usageerrors2.vb#5)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.exception.class/cs/usageerrors2.cs" interactive="try-dotnet" id="Snippet5"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.exception.class/vb/usageerrors2.vb" id="Snippet5"::: Instead of using exception handling for usage errors, you can use the method to identify usage errors in debug builds, and the method to identify usage errors in both debug and release builds. For more information, see [Assertions in Managed Code](/visualstudio/debugger/assertions-in-managed-code). @@ -292,9 +292,9 @@ Stack Trace: ## Examples The following example demonstrates a `catch` block that is defined to handle errors. This `catch` block also catches errors, because derives from and there is no `catch` block explicitly defined for errors. - [!code-cpp[CatchException#1](~/samples/snippets/cpp/VS_Snippets_CLR/CatchException/CPP/catchexception.cpp#1)] - [!code-csharp[CatchException#1](~/samples/snippets/csharp/VS_Snippets_CLR/CatchException/CS/catchexception.cs#1)] - [!code-vb[CatchException#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/CatchException/VB/catchexception.vb#1)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/CatchException/CPP/catchexception.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/CatchException/CS/catchexception.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/CatchException/VB/catchexception.vb" id="Snippet1"::: ]]> diff --git a/xml/System/Object.xml b/xml/System/Object.xml index 6a3aa192ea8..53092c962f6 100644 --- a/xml/System/Object.xml +++ b/xml/System/Object.xml @@ -649,18 +649,18 @@ and the interface. The type is to simply return that value. The following example shows such an implementation for a `Number` structure. - [!code-csharp[System.Object.GetHashCode#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.gethashcode/cs/direct1.cs#1)] - [!code-vb[System.Object.GetHashCode#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.gethashcode/vb/direct1.vb#1)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.gethashcode/cs/direct1.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.gethashcode/vb/direct1.vb" id="Snippet1"::: Frequently, a type has multiple data fields that can participate in generating the hash code. One way to generate a hash code is to combine these fields using an `XOR (eXclusive OR)` operation, as shown in the following example. - [!code-csharp[System.Object.GetHashCode#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.gethashcode/cs/xor1.cs#2)] - [!code-vb[System.Object.GetHashCode#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.gethashcode/vb/xor1.vb#2)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.gethashcode/cs/xor1.cs" interactive="try-dotnet" id="Snippet2"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.gethashcode/vb/xor1.vb" id="Snippet2"::: The previous example returns the same hash code for (n1, n2) and (n2, n1), and so may generate more collisions than are desirable. A number of solutions are available so that hash codes in these cases are not identical. One is to return the hash code of a `Tuple` object that reflects the order of each field. The following example shows a possible implementation that uses the class. Note, though, that the performance overhead of instantiating a `Tuple` object may significantly impact the overall performance of an application that stores large numbers of objects in hash tables. - [!code-csharp[System.Object.GetHashCode#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.gethashcode/cs/xor2.cs#3)] - [!code-vb[System.Object.GetHashCode#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.gethashcode/vb/xor2.vb#3)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.gethashcode/cs/xor2.cs" interactive="try-dotnet" id="Snippet3"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.gethashcode/vb/xor2.vb" id="Snippet3"::: A second alternative solution involves weighting the individual hash codes by left-shifting the hash codes of successive fields by two or more bits. Optimally, bits shifted beyond bit 31 should wrap around rather than be discarded. Since bits are discarded by the left-shift operators in both C# and Visual Basic, this requires creating a left shift-and-wrap method like the following: @@ -669,8 +669,8 @@ and the interface. The diff --git a/xml/System/Random.xml b/xml/System/Random.xml index 472b2c29185..1813cfb04c9 100644 --- a/xml/System/Random.xml +++ b/xml/System/Random.xml @@ -544,15 +544,15 @@ The following example uses the parameterless constructor to instantiate three method to generate a specific number of random numbers requested by the user. The method is used to get customer input. - [!code-cpp[System.Random.Next#5](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next3.cpp#5)] - [!code-csharp[System.Random.Next#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Next/CS/next3.cs#5)] - [!code-vb[System.Random.Next#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next3.vb#5)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next3.cpp" id="Snippet5"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Next/CS/next3.cs" interactive="try-dotnet-method" id="Snippet5"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next3.vb" id="Snippet5"::: The following example derives a class from to generate a sequence of random numbers whose distribution differs from the uniform distribution generated by the method of the base class. It overrides the method to provide the distribution of random numbers, and overrides the method to use series of random numbers. - [!code-cpp[System.Random.Sample#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Sample/cpp/sampleex.cpp#1)] - [!code-csharp[System.Random.Sample#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Sample/CS/sample.cs#1)] - [!code-vb[System.Random.Sample#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Sample/VB/sample.vb#1)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Sample/cpp/sampleex.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Random.Sample/CS/sample.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Sample/VB/sample.vb" id="Snippet1"::: ]]> diff --git a/xml/System/String.xml b/xml/System/String.xml index 109cbfbcc19..e3144215727 100644 --- a/xml/System/String.xml +++ b/xml/System/String.xml @@ -743,25 +743,25 @@ Examples of instantiating strings: ## Example 1: Use string assignment The following example creates a new string by assigning it a string literal. It creates a second string by assigning the value of the first string to it. These are the two most common ways to instantiate a new object. - [!code-cpp[System.String.ctor#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/assignment.cpp#1)] - [!code-csharp[System.String.ctor#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.string.ctor/cs/ctor1.cs#1)] - [!code-vb[System.String.ctor#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.string.ctor/vb/ctor1.vb#1)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/assignment.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.string.ctor/cs/ctor1.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.string.ctor/vb/ctor1.vb" id="Snippet1"::: ## Example 2: Use a character array The following example demonstrates how to create a new object from a character array. - [!code-cpp[stringexample1#1](~/samples/snippets/cpp/VS_Snippets_CLR/stringexample1/CPP/source.cpp#1)] - [!code-csharp[stringexample1#1](~/samples/snippets/csharp/VS_Snippets_CLR/stringexample1/CS/source.cs#1)] - [!code-vb[stringexample1#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/stringexample1/VB/source.vb#1)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/stringexample1/CPP/source.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/stringexample1/CS/source.cs" interactive="try-dotnet-method" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/stringexample1/VB/source.vb" id="Snippet1"::: ## Example 3: Use a portion of a character array and repeating a single character The following example demonstrates how to create a new object from a portion of a character array, and how to create a new object that contains multiple occurrences of a single character. - [!code-cpp[stringexample1#3](~/samples/snippets/cpp/VS_Snippets_CLR/stringexample1/CPP/source.cpp#3)] - [!code-csharp[stringexample1#3](~/samples/snippets/csharp/VS_Snippets_CLR/stringexample1/CS/source.cs#3)] - [!code-vb[stringexample1#3](~/samples/snippets/visualbasic/VS_Snippets_CLR/stringexample1/VB/source.vb#3)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/stringexample1/CPP/source.cpp" id="Snippet3"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/stringexample1/CS/source.cs" interactive="try-dotnet-method" id="Snippet3"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/stringexample1/VB/source.vb" id="Snippet3"::: ## Example 4: Use a pointer to a character array @@ -7954,6 +7954,18 @@ The `comparisonType` parameter is a enumeration m Indicates whether this string is in a particular Unicode normalization form. + + + @@ -8000,15 +8012,6 @@ The `comparisonType` parameter is a enumeration m For a description of supported Unicode normalization forms, see . - - -## Examples - The following example determines whether a string is successfully normalized to various normalization forms. - - [!code-cpp[string.normalize#1](~/samples/snippets/cpp/VS_Snippets_CLR/string.normalize/CPP/norm.cpp#1)] - [!code-csharp[string.normalize#1](~/samples/snippets/csharp/VS_Snippets_CLR/string.normalize/CS/norm.cs#1)] - [!code-vb[string.normalize#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/string.normalize/VB/norm.vb#1)] - ]]> The current instance contains invalid Unicode characters. @@ -8070,15 +8073,6 @@ The `comparisonType` parameter is a enumeration m For a description of supported Unicode normalization forms, see . - - -## Examples - The following example demonstrates the and methods. - - [!code-cpp[string.normalize#1](~/samples/snippets/cpp/VS_Snippets_CLR/string.normalize/CPP/norm.cpp#1)] - [!code-csharp[string.normalize#1](~/samples/snippets/csharp/VS_Snippets_CLR/string.normalize/CS/norm.cs#1)] - [!code-vb[string.normalize#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/string.normalize/VB/norm.vb#1)] - ]]> The current instance contains invalid Unicode characters. @@ -9936,9 +9930,9 @@ A string is empty if it is explicitly assigned an empty string ("") or property. - [!code-cpp[string.length#1](~/samples/snippets/cpp/VS_Snippets_CLR/string.length/CPP/length.cpp#1)] - [!code-csharp-interactive[string.length#1](~/samples/snippets/csharp/VS_Snippets_CLR/string.length/CS/length.cs#1)] - [!code-vb[string.length#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/string.length/VB/length.vb#1)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/string.length/CPP/length.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/string.length/CS/length.cs" interactive="try-dotnet-method" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/string.length/VB/length.vb" id="Snippet1"::: ]]> @@ -9953,6 +9947,18 @@ A string is empty if it is explicitly assigned an empty string ("") or Returns a new string whose binary representation is in a particular Unicode normalization form. + + + @@ -10016,15 +10022,6 @@ A string is empty if it is explicitly assigned an empty string ("") or . - - -## Examples - The following example normalizes a string to each of four normalization forms, confirms the string was normalized to the specified normalization form, then lists the code points in the normalized string. - - [!code-cpp[string.normalize#1](~/samples/snippets/cpp/VS_Snippets_CLR/string.normalize/CPP/norm.cpp#1)] - [!code-csharp[string.normalize#1](~/samples/snippets/csharp/VS_Snippets_CLR/string.normalize/CS/norm.cs#1)] - [!code-vb[string.normalize#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/string.normalize/VB/norm.vb#1)] - ]]> The current instance contains invalid Unicode characters. @@ -10095,15 +10092,6 @@ A string is empty if it is explicitly assigned an empty string ("") or . - - -## Examples - The following example normalizes a string to each of four normalization forms, confirms the string was normalized to the specified normalization form, then lists the code points in the normalized string. - - [!code-cpp[string.normalize#1](~/samples/snippets/cpp/VS_Snippets_CLR/string.normalize/CPP/norm.cpp#1)] - [!code-csharp[string.normalize#1](~/samples/snippets/csharp/VS_Snippets_CLR/string.normalize/CS/norm.cs#1)] - [!code-vb[string.normalize#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/string.normalize/VB/norm.vb#1)] - ]]> The current instance contains invalid Unicode characters. diff --git a/xml/System/Type.xml b/xml/System/Type.xml index fc2af22ec4d..2febd85630e 100644 --- a/xml/System/Type.xml +++ b/xml/System/Type.xml @@ -171,9 +171,9 @@ The code example uses the to invoke the method on the string "Hello, World!", and displays the result. - [!code-cpp[System.Type#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Type/cpp/source.cpp#1)] - [!code-csharp[System.Type#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Type/cs/source.cs#1)] - [!code-vb[System.Type#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Type/vb/source.vb#1)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Type/cpp/source.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Type/cs/source.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Type/vb/source.vb" id="Snippet1"::: ]]>