diff --git a/xml/System.Collections.Specialized/NameValueCollection.xml b/xml/System.Collections.Specialized/NameValueCollection.xml index 8511ef72011..b418cfd74ed 100644 --- a/xml/System.Collections.Specialized/NameValueCollection.xml +++ b/xml/System.Collections.Specialized/NameValueCollection.xml @@ -63,9 +63,9 @@ ## Examples - [!code-cpp[System.Collections.Specialized.NameValueCollection2#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CPP/nvc.cpp#1)] - [!code-csharp[System.Collections.Specialized.NameValueCollection2#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CS/nvc.cs#1)] - [!code-vb[System.Collections.Specialized.NameValueCollection2#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/VB/nvc.vb#1)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CPP/nvc.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CS/nvc.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/VB/nvc.vb" id="Snippet1"::: ]]> diff --git a/xml/System.Linq/Queryable.xml b/xml/System.Linq/Queryable.xml index f06be7917ee..c1128427ac5 100644 --- a/xml/System.Linq/Queryable.xml +++ b/xml/System.Linq/Queryable.xml @@ -8334,8 +8334,8 @@ If `count` is not a positive number, this method returns an empty queryable sequ ## Examples The following code example demonstrates how to use to obtain the set union of two sequences. - [!code-csharp[System.Linq.Queryable#109](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Queryable/CS/queryable.cs#109)] - [!code-vb[System.Linq.Queryable#109](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Queryable/VB/queryable.vb#109)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Queryable/CS/queryable.cs" interactive="try-dotnet-method" id="Snippet109"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Queryable/VB/queryable.vb" id="Snippet109"::: ]]> diff --git a/xml/System.Text/Encoder.xml b/xml/System.Text/Encoder.xml index 0cbbea27b26..f762e89efe2 100644 --- a/xml/System.Text/Encoder.xml +++ b/xml/System.Text/Encoder.xml @@ -72,9 +72,9 @@ ## Examples The following example demonstrates how to convert an array of Unicode characters into blocks of bytes using a specified encoding. For comparison, the array of characters is first encoded using . Next, the array of characters is encoded using an . - [!code-cpp[System.Text.Encoder Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder Example/CPP/snippet.cpp#1)] - [!code-csharp[System.Text.Encoder Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.Encoder Example/CS/snippet.cs#1)] - [!code-vb[System.Text.Encoder Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoder Example/VB/snippet.vb#1)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder Example/CPP/snippet.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.Encoder Example/CS/snippet.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoder Example/VB/snippet.vb" id="Snippet1"::: ]]> diff --git a/xml/System.Text/UTF8Encoding.xml b/xml/System.Text/UTF8Encoding.xml index 5985eb1202d..edec222b62d 100644 --- a/xml/System.Text/UTF8Encoding.xml +++ b/xml/System.Text/UTF8Encoding.xml @@ -1935,14 +1935,14 @@ ## Examples The following example uses the method to return the Unicode byte order mark encoded in UTF-8 format. Notice that the parameterless constructor for does not provide a preamble. - [!code-cpp[System.Text.UTF8Encoding.GetPreamble Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CPP/getpreamble-.cpp#1)] - [!code-csharp[System.Text.UTF8Encoding.GetPreamble Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CS/getpreamble-.cs#1)] - [!code-vb[System.Text.UTF8Encoding.GetPreamble Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/VB/getpreamble-.vb#1)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CPP/getpreamble-.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CS/getpreamble-.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/VB/getpreamble-.vb" id="Snippet1"::: The following example instantiates two objects, the first by calling the parameterless constructor, which does not provide a BOM, and the second by calling the constructor with its `encoderShouldEmitUTF8Identifier` argument set to `true`. It then calls the method to write the BOM to a file before writing a UF8-encoded string. As the console output from the example shows, the file that saves the bytes from the second encoder has three more bytes than the first. - [!code-csharp[System.Text.UTF8Encoding.GetPreamble#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.utf8encoding.getpreamble/cs/getpreamble1.cs#1)] - [!code-vb[System.Text.UTF8Encoding.GetPreamble#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.utf8encoding.getpreamble/vb/getpreamble1.vb#1)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.utf8encoding.getpreamble/cs/getpreamble1.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.utf8encoding.getpreamble/vb/getpreamble1.vb" id="Snippet1"::: You can also compare the files by using the `fc` command in a console window, or you can inspect the files in a text editor that includes a Hex View mode. Note that when the file is opened in an editor that supports UTF-8, the BOM is not displayed. diff --git a/xml/System/ArgumentOutOfRangeException.xml b/xml/System/ArgumentOutOfRangeException.xml index bf3bb28450c..2707764ec24 100644 --- a/xml/System/ArgumentOutOfRangeException.xml +++ b/xml/System/ArgumentOutOfRangeException.xml @@ -77,8 +77,8 @@ The conditions in which an exception i 1. The collection has no members, and your code assumes that it does. The following example attempts to retrieve the first element of a collection that has no elements: - [!code-csharp[System.ArgumentOutOfRangeException#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/NoElements.cs#4)] - [!code-vb[System.ArgumentOutOfRangeException#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/NoElements.vb#4)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/NoElements.cs" interactive="try-dotnet" id="Snippet4"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/NoElements.vb" id="Snippet4"::: To prevent the exception, check whether the collection's `Count` property is greater than zero before attempting to retrieve any members, as the following code fragment does. @@ -97,8 +97,8 @@ The conditions in which an exception i 3. You're attempting to retrieve an item whose index is negative. This usually occurs because you've searched a collection for the index of a particular element and have erroneously assumed that the search is successful. In the following example, the call to the method fails to find a string equal to "Z" and so returns -1. However, this is an invalid index value. - [!code-csharp[System.ArgumentOutOfRangeException#6](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/BadSearch.cs#6)] - [!code-vb[System.ArgumentOutOfRangeException#6](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/BadSearch.vb#6)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/BadSearch.cs" interactive="try-dotnet" id="Snippet6"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/BadSearch.vb" id="Snippet6"::: To prevent the exception, check that the search is successful by making sure that the returned index is greater than or equal to zero before attempting to retrieve the item from the collection, as the following code fragment does. @@ -107,8 +107,8 @@ The conditions in which an exception i 4. You're attempting to retrieve an element whose index is equal to the value of the collection's `Count` property, as the following example illustrates. - [!code-csharp[System.ArgumentOutOfRangeException#8](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/OOR2.cs#8)] - [!code-vb[System.ArgumentOutOfRangeException#8](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/OOR2.vb#8)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/OOR2.cs" interactive="try-dotnet" id="Snippet8"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/OOR2.vb" id="Snippet8"::: Because collections in .NET use zero-based indexing, the first element of the collection is at index 0, and the last element is at index `Count` - 1. You can eliminate the error by ensuring that you access the last element at index `Count` - 1, as the following code does. @@ -140,8 +140,8 @@ The conditions in which an exception i To eliminate the exception, validate the value returned by the string search method before calling the string manipulation method. - [!code-csharp[System.ArgumentOutOfRangeException#18](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/NoFind2.cs#18)] - [!code-vb[System.ArgumentOutOfRangeException#18](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/NoFind2.vb#18)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/NoFind2.cs" interactive="try-dotnet" id="Snippet18"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/NoFind2.vb" id="Snippet18"::: 3. You've attempted to extract a substring that is outside the range of the current string. @@ -163,8 +163,8 @@ The conditions in which an exception i The following example defines a `FindWords` method that uses the method to identify space characters and punctuation marks in a string and returns an array that contains the words found in the string. - [!code-csharp[System.ArgumentOutOfRangeException#19](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/FindWords1.cs#19)] - [!code-vb[System.ArgumentOutOfRangeException#19](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/FindWords1.vb#19)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/FindWords1.cs" interactive="try-dotnet" id="Snippet19"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/FindWords1.vb" id="Snippet19"::: - You have passed a negative number to a method with an argument that requires only positive numbers and zero, or you have passed either a negative number or zero to a method with an argument that requires only positive numbers. @@ -215,8 +215,8 @@ For a list of initial property values for an instance of exception is thrown. - [!code-csharp[ArgumentOutOfRangeException#1](~/samples/snippets/csharp/VS_Snippets_CLR/ArgumentOutOfRangeException/CS/program.cs#1)] - [!code-vb[ArgumentOutOfRangeException#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/ArgumentOutOfRangeException/VB/program.vb#1)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/ArgumentOutOfRangeException/CS/program.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/ArgumentOutOfRangeException/VB/program.vb" id="Snippet1"::: ]]> diff --git a/xml/System/IndexOutOfRangeException.xml b/xml/System/IndexOutOfRangeException.xml index 48b0a215c1b..5597a1a3811 100644 --- a/xml/System/IndexOutOfRangeException.xml +++ b/xml/System/IndexOutOfRangeException.xml @@ -67,8 +67,8 @@ To correct the error, you can use code like the following. - [!code-csharp[System.IndexOutOfRangeException#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.indexoutofrangeexception/cs/length2.cs#4)] - [!code-vb[System.IndexOutOfRangeException#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.indexoutofrangeexception/vb/length2.vb#4)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.indexoutofrangeexception/cs/length2.cs" interactive="try-dotnet" id="Snippet4"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.indexoutofrangeexception/vb/length2.vb" id="Snippet4"::: Alternately, instead of iterating all the elements in the array by their index, you can use the `foreach` statement (in C#) or the `For Each` statement (in Visual Basic). @@ -117,8 +117,8 @@ To correct the error, as the following example does, you can call the method instead of making assumptions about the starting index of an array. - [!code-csharp[System.IndexOutOfRangeException#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.indexoutofrangeexception/cs/nonzero2.cs#2)] - [!code-vb[System.IndexOutOfRangeException#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.indexoutofrangeexception/vb/nonzero2.vb#2)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.indexoutofrangeexception/cs/nonzero2.cs" interactive="try-dotnet" id="Snippet2"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.indexoutofrangeexception/vb/nonzero2.vb" id="Snippet2"::: Note that when you call the method to get the starting index of an array, you should also call the method to get its ending index. @@ -129,8 +129,8 @@ The iteration construct returns each value in an array or collection, not its index. To eliminate the exception, use this code. - [!code-csharp[System.IndexOutOfRangeException#8](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.indexoutofrangeexception/cs/foreach2.cs#8)] - [!code-vb[System.IndexOutOfRangeException#8](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.indexoutofrangeexception/vb/foreach2.vb#8)] + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.indexoutofrangeexception/cs/foreach2.cs" interactive="try-dotnet" id="Snippet8"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.indexoutofrangeexception/vb/foreach2.vb" id="Snippet8"::: - Providing an invalid column name to the property. diff --git a/xml/System/Type.xml b/xml/System/Type.xml index fc2af22ec4d..35a83c74577 100644 --- a/xml/System/Type.xml +++ b/xml/System/Type.xml @@ -11864,9 +11864,9 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance The following code example and table illustrate some of these terms and invariants. The `Derived` class is of particular interest because its base type is a constructed type that has a mixture of types and type parameters in its type argument list. - [!code-cpp[System.Type.IsGenericType#2](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/remarks.cpp#2)] - [!code-csharp[System.Type.IsGenericType#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Type.IsGenericType/cs/remarks.cs#2)] - [!code-vb[System.Type.IsGenericType#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.IsGenericType/vb/remarks.vb#2)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/remarks.cpp" id="Snippet2"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Type.IsGenericType/cs/remarks.cs" id="Snippet2"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.IsGenericType/vb/remarks.vb" id="Snippet2"::: The following table shows examples that use and build on the classes `Base`, `Derived`, and `G`. When the C++ and C# code is the same, only one entry is shown. @@ -11884,9 +11884,9 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following code example displays the value of the , , , and properties for the types described in the Remarks section. For explanations of the property values, see the accompanying table in Remarks. - [!code-cpp[System.Type.IsGenericType#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/source.cpp#1)] - [!code-csharp[System.Type.IsGenericType#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Type.IsGenericType/cs/source.cs#1)] - [!code-vb[System.Type.IsGenericType#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.IsGenericType/vb/source.vb#1)] + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/source.cpp" id="Snippet1"::: + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Type.IsGenericType/cs/source.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.IsGenericType/vb/source.vb" id="Snippet1"::: ]]>