diff --git a/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp b/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp
index 4994a07ea6b..d761e8e9ec0 100644
--- a/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp
+++ b/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp
@@ -1,56 +1,47 @@
//
using namespace System;
-void main1();
-void main2();
-void main()
-{
- main1();
- Console::WriteLine();
- main2();
-}
-void PrintValues( Array^ myArr );
-void main1()
+void main()
{
// Creates and initializes two new Array instances.
- Array^ mySourceArray = Array::CreateInstance( String::typeid, 6 );
- mySourceArray->SetValue( "three", 0 );
- mySourceArray->SetValue( "napping", 1 );
- mySourceArray->SetValue( "cats", 2 );
- mySourceArray->SetValue( "in", 3 );
- mySourceArray->SetValue( "the", 4 );
- mySourceArray->SetValue( "barn", 5 );
- Array^ myTargetArray = Array::CreateInstance( String::typeid, 15 );
- myTargetArray->SetValue( "The", 0 );
- myTargetArray->SetValue( "quick", 1 );
- myTargetArray->SetValue( "brown", 2 );
- myTargetArray->SetValue( "fox", 3 );
- myTargetArray->SetValue( "jumps", 4 );
- myTargetArray->SetValue( "over", 5 );
- myTargetArray->SetValue( "the", 6 );
- myTargetArray->SetValue( "lazy", 7 );
- myTargetArray->SetValue( "dog", 8 );
+ Array^ mySourceArray = Array::CreateInstance(String::typeid, 6);
+ mySourceArray->SetValue("three", 0);
+ mySourceArray->SetValue("napping", 1);
+ mySourceArray->SetValue("cats", 2);
+ mySourceArray->SetValue("in", 3);
+ mySourceArray->SetValue("the", 4);
+ mySourceArray->SetValue("barn", 5);
+ Array^ myTargetArray = Array::CreateInstance(String::typeid, 15);
+ myTargetArray->SetValue("The", 0);
+ myTargetArray->SetValue("quick", 1);
+ myTargetArray->SetValue("brown", 2);
+ myTargetArray->SetValue("fox", 3);
+ myTargetArray->SetValue("jumps", 4);
+ myTargetArray->SetValue("over", 5);
+ myTargetArray->SetValue("the", 6);
+ myTargetArray->SetValue("lazy", 7);
+ myTargetArray->SetValue("dog", 8);
// Displays the values of the Array.
- Console::WriteLine( "The target Array instance contains the following (before and after copying):" );
- PrintValues( myTargetArray );
+ Console::WriteLine( "The target Array instance contains the following (before and after copying):");
+ PrintValues(myTargetArray);
// Copies the source Array to the target Array, starting at index 6.
- mySourceArray->CopyTo( myTargetArray, 6 );
+ mySourceArray->CopyTo(myTargetArray, 6);
// Displays the values of the Array.
- PrintValues( myTargetArray );
+ PrintValues(myTargetArray);
}
-void PrintValues( Array^ myArr )
+void PrintValues(Array^ myArr)
{
System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator();
int i = 0;
- int cols = myArr->GetLength( myArr->Rank - 1 );
- while ( myEnumerator->MoveNext() )
+ int cols = myArr->GetLength(myArr->Rank - 1);
+ while (myEnumerator->MoveNext())
{
- if ( i < cols )
+ if (i < cols)
{
i++;
}
@@ -60,13 +51,12 @@ void PrintValues( Array^ myArr )
i = 1;
}
- Console::Write( " {0}", myEnumerator->Current );
+ Console::Write( " {0}", myEnumerator->Current);
}
Console::WriteLine();
}
-
/*
This code produces the following output.
@@ -75,63 +65,3 @@ void PrintValues( Array^ myArr )
The quick brown fox jumps over three napping cats in the barn
*/
//
-//
-void PrintIndexAndValues( Array^ myArray );
-void main2()
-{
- // Creates and initializes the source Array.
- Array^ myArrayZero = Array::CreateInstance( String::typeid, 3 );
- myArrayZero->SetValue( "zero", 0 );
- myArrayZero->SetValue( "one", 1 );
-
- // Displays the source Array.
- Console::WriteLine( "The array with lowbound=0 contains:" );
- PrintIndexAndValues( myArrayZero );
-
- // Creates and initializes the target Array.
- array^myArrLen = {4};
- array^myArrLow = {2};
- Array^ myArrayTwo = Array::CreateInstance( String::typeid, myArrLen, myArrLow );
- myArrayTwo->SetValue( "two", 2 );
- myArrayTwo->SetValue( "three", 3 );
- myArrayTwo->SetValue( "four", 4 );
- myArrayTwo->SetValue( "five", 5 );
-
- // Displays the target Array.
- Console::WriteLine( "The array with lowbound=2 contains:" );
- PrintIndexAndValues( myArrayTwo );
-
- // Copy from the array with lowbound=0 to the array with lowbound=2.
- myArrayZero->CopyTo( myArrayTwo, 3 );
-
- // Displays the modified target Array.
- Console::WriteLine( "\nAfter copying at relative index 1:" );
- PrintIndexAndValues( myArrayTwo );
-}
-
-void PrintIndexAndValues( Array^ myArray )
-{
- for ( int i = myArray->GetLowerBound( 0 ); i <= myArray->GetUpperBound( 0 ); i++ )
- Console::WriteLine( "\t[{0}]:\t{1}", i, myArray->GetValue( i ) );
-}
-
-/*
- This code produces the following output.
-
- The array with lowbound=0 contains:
- [0]: zero
- [1]: one
- [2]:
- The array with lowbound=2 contains:
- [2]: two
- [3]: three
- [4]: four
- [5]: five
-
- After copying at relative index 1:
- [2]: two
- [3]: zero
- [4]: one
- [5]:
- */
-//
diff --git a/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source2.cpp b/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source2.cpp
new file mode 100644
index 00000000000..ca74d220df4
--- /dev/null
+++ b/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source2.cpp
@@ -0,0 +1,61 @@
+//
+using namespace System;
+
+void main()
+{
+ // Creates and initializes the source Array.
+ Array^ myArrayZero = Array::CreateInstance(String::typeid, 3);
+ myArrayZero->SetValue("zero", 0);
+ myArrayZero->SetValue("one", 1);
+
+ // Displays the source Array.
+ Console::WriteLine("The array with lowbound=0 contains:");
+ PrintIndexAndValues(myArrayZero);
+
+ // Creates and initializes the target Array.
+ array^myArrLen = {4};
+ array^myArrLow = {2};
+ Array^ myArrayTwo = Array::CreateInstance(String::typeid, myArrLen, myArrLow);
+ myArrayTwo->SetValue("two", 2);
+ myArrayTwo->SetValue("three", 3);
+ myArrayTwo->SetValue("four", 4);
+ myArrayTwo->SetValue("five", 5);
+
+ // Displays the target Array.
+ Console::WriteLine("The array with lowbound=2 contains:");
+ PrintIndexAndValues(myArrayTwo);
+
+ // Copy from the array with lowbound=0 to the array with lowbound=2.
+ myArrayZero->CopyTo(myArrayTwo, 3);
+
+ // Displays the modified target Array.
+ Console::WriteLine("\nAfter copying at relative index 1:");
+ PrintIndexAndValues(myArrayTwo);
+}
+
+void PrintIndexAndValues(Array^ myArray)
+{
+ for (int i = myArray->GetLowerBound(0); i <= myArray->GetUpperBound(0); i++)
+ Console::WriteLine("\t[{0}]:\t{1}", i, myArray->GetValue(i));
+}
+
+/*
+ This code produces the following output.
+
+ The array with lowbound=0 contains:
+ [0]: zero
+ [1]: one
+ [2]:
+ The array with lowbound=2 contains:
+ [2]: two
+ [3]: three
+ [4]: four
+ [5]: five
+
+ After copying at relative index 1:
+ [2]: two
+ [3]: zero
+ [4]: one
+ [5]:
+ */
+//
diff --git a/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CS/source.cs b/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CS/source.cs
index 9f75bb8ea43..43ea1853b00 100644
--- a/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CS/source.cs
+++ b/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CS/source.cs
@@ -1,119 +1,69 @@
-//
- using System;
- public class SamplesArray {
-
- public static void Main() {
-
- // Creates and initializes two new Arrays.
- Array mySourceArray=Array.CreateInstance( typeof(String), 6 );
- mySourceArray.SetValue( "three", 0 );
- mySourceArray.SetValue( "napping", 1 );
- mySourceArray.SetValue( "cats", 2 );
- mySourceArray.SetValue( "in", 3 );
- mySourceArray.SetValue( "the", 4 );
- mySourceArray.SetValue( "barn", 5 );
- Array myTargetArray=Array.CreateInstance( typeof(String), 15 );
- myTargetArray.SetValue( "The", 0 );
- myTargetArray.SetValue( "quick", 1 );
- myTargetArray.SetValue( "brown", 2 );
- myTargetArray.SetValue( "fox", 3 );
- myTargetArray.SetValue( "jumps", 4 );
- myTargetArray.SetValue( "over", 5 );
- myTargetArray.SetValue( "the", 6 );
- myTargetArray.SetValue( "lazy", 7 );
- myTargetArray.SetValue( "dog", 8 );
-
- // Displays the values of the Array.
- Console.WriteLine( "The target Array contains the following (before and after copying):" );
- PrintValues( myTargetArray, ' ' );
-
- // Copies the source Array to the target Array, starting at index 6.
- mySourceArray.CopyTo( myTargetArray, 6 );
-
- // Displays the values of the Array.
- PrintValues( myTargetArray, ' ' );
- }
-
- public static void PrintValues( Array myArr, char mySeparator ) {
- System.Collections.IEnumerator myEnumerator = myArr.GetEnumerator();
- int i = 0;
- int cols = myArr.GetLength( myArr.Rank - 1 );
- while ( myEnumerator.MoveNext() ) {
- if ( i < cols ) {
- i++;
- } else {
+//
+using System;
+
+public class SamplesArray
+{
+
+ public static void Main()
+ {
+
+ // Creates and initializes two new Arrays.
+ Array mySourceArray=Array.CreateInstance(typeof(String), 6);
+ mySourceArray.SetValue("three", 0);
+ mySourceArray.SetValue("napping", 1);
+ mySourceArray.SetValue("cats", 2);
+ mySourceArray.SetValue("in", 3);
+ mySourceArray.SetValue("the", 4);
+ mySourceArray.SetValue("barn", 5);
+ Array myTargetArray=Array.CreateInstance(typeof(String), 15);
+ myTargetArray.SetValue("The", 0);
+ myTargetArray.SetValue("quick", 1);
+ myTargetArray.SetValue("brown", 2);
+ myTargetArray.SetValue("fox", 3);
+ myTargetArray.SetValue("jumps", 4);
+ myTargetArray.SetValue("over", 5);
+ myTargetArray.SetValue("the", 6);
+ myTargetArray.SetValue("lazy", 7);
+ myTargetArray.SetValue("dog", 8);
+
+ // Displays the values of the Array.
+ Console.WriteLine("The target Array contains the following (before and after copying):");
+ PrintValues(myTargetArray, ' ');
+
+ // Copies the source Array to the target Array, starting at index 6.
+ mySourceArray.CopyTo(myTargetArray, 6);
+
+ // Displays the values of the Array.
+ PrintValues(myTargetArray, ' ');
+ }
+
+ public static void PrintValues(Array myArr, char mySeparator)
+ {
+
+ System.Collections.IEnumerator myEnumerator = myArr.GetEnumerator();
+ int i = 0;
+ int cols = myArr.GetLength(myArr.Rank - 1);
+ while (myEnumerator.MoveNext())
+ {
+ if (i < cols)
+ {
+ i++;
+ }
+ else
+ {
Console.WriteLine();
i = 1;
- }
- Console.Write( "{0}{1}", mySeparator, myEnumerator.Current );
- }
- Console.WriteLine();
- }
- }
- /*
- This code produces the following output.
-
- The target Array contains the following (before and after copying):
- The quick brown fox jumps over the lazy dog
- The quick brown fox jumps over three napping cats in the barn
- */
+ }
+ Console.Write("{0}{1}", mySeparator, myEnumerator.Current);
+ }
+ Console.WriteLine();
+ }
+}
+/*
+This code produces the following output.
+
+The target Array contains the following (before and after copying):
+ The quick brown fox jumps over the lazy dog
+ The quick brown fox jumps over three napping cats in the barn
+*/
//
-//
- public class SamplesArray2{
-
- public static void Main() {
- // Creates and initializes the source Array.
- Array myArrayZero=Array.CreateInstance( typeof(String), 3 );
- myArrayZero.SetValue( "zero", 0 );
- myArrayZero.SetValue( "one", 1 );
-
- // Displays the source Array.
- Console.WriteLine( "The array with lower bound=0 contains:" );
- PrintIndexAndValues( myArrayZero );
-
- // Creates and initializes the target Array.
- int[] myArrLen = { 4 };
- int[] myArrLow = { 2 };
- Array myArrayTwo=Array.CreateInstance( typeof(String), myArrLen, myArrLow );
- myArrayTwo.SetValue( "two", 2 );
- myArrayTwo.SetValue( "three", 3 );
- myArrayTwo.SetValue( "four", 4 );
- myArrayTwo.SetValue( "five", 5 );
-
- // Displays the target Array.
- Console.WriteLine( "The array with lower bound=2 contains:" );
- PrintIndexAndValues( myArrayTwo );
-
- // Copies from the array with lower bound=0 to the array with lower bound=2.
- myArrayZero.CopyTo( myArrayTwo, 3 );
-
- // Displays the modified target Array.
- Console.WriteLine( "\nAfter copying to the target array from index 3:" );
- PrintIndexAndValues( myArrayTwo );
- }
-
- public static void PrintIndexAndValues( Array myArray ) {
- for ( int i = myArray.GetLowerBound(0); i <= myArray.GetUpperBound(0); i++ )
- Console.WriteLine( "\t[{0}]:\t{1}", i, myArray.GetValue( i ) );
- }
- }
- /*
- This code produces the following output.
-
- The array with lower bound=0 contains:
- [0]: zero
- [1]: one
- [2]:
- The array with lower bound=2 contains:
- [2]: two
- [3]: three
- [4]: four
- [5]: five
-
- After copying to the target array from index 3:
- [2]: two
- [3]: zero
- [4]: one
- [5]:
- */
-//
diff --git a/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CS/source2.cs b/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CS/source2.cs
new file mode 100644
index 00000000000..a65c09d282b
--- /dev/null
+++ b/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CS/source2.cs
@@ -0,0 +1,64 @@
+//
+using System;
+
+public class SamplesArray2
+{
+
+ public static void Main()
+ {
+ // Creates and initializes the source Array.
+ Array myArrayZero=Array.CreateInstance(typeof(String), 3);
+ myArrayZero.SetValue("zero", 0);
+ myArrayZero.SetValue("one", 1);
+
+ // Displays the source Array.
+ Console.WriteLine("The array with lower bound=0 contains:");
+ PrintIndexAndValues(myArrayZero);
+
+ // Creates and initializes the target Array.
+ int[] myArrLen = { 4 };
+ int[] myArrLow = { 2 };
+ Array myArrayTwo=Array.CreateInstance(typeof(String), myArrLen, myArrLow);
+ myArrayTwo.SetValue("two", 2);
+ myArrayTwo.SetValue("three", 3);
+ myArrayTwo.SetValue("four", 4);
+ myArrayTwo.SetValue("five", 5);
+
+ // Displays the target Array.
+ Console.WriteLine("The array with lower bound=2 contains:");
+ PrintIndexAndValues(myArrayTwo);
+
+ // Copies from the array with lower bound=0 to the array with lower bound=2.
+ myArrayZero.CopyTo(myArrayTwo, 3);
+
+ // Displays the modified target Array.
+ Console.WriteLine("\nAfter copying to the target array from index 3:");
+ PrintIndexAndValues(myArrayTwo);
+ }
+
+ public static void PrintIndexAndValues(Array myArray)
+ {
+ for (int i = myArray.GetLowerBound(0); i <= myArray.GetUpperBound(0); i++)
+ Console.WriteLine("\t[{0}]:\t{1}", i, myArray.GetValue(i));
+ }
+}
+/*
+This code produces the following output.
+
+The array with lower bound=0 contains:
+ [0]: zero
+ [1]: one
+ [2]:
+The array with lower bound=2 contains:
+ [2]: two
+ [3]: three
+ [4]: four
+ [5]: five
+
+After copying to the target array from index 3:
+ [2]: two
+ [3]: zero
+ [4]: one
+ [5]:
+*/
+//
diff --git a/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source.vb b/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source.vb
index 555ba38b62a..f768b2788b6 100644
--- a/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source.vb
+++ b/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source.vb
@@ -54,71 +54,7 @@ End Class
' This code produces the following output.
'
-' The target Array contains the following (before and after copying):
+' The target Array contains the following (before and after copying):
' The quick brown fox jumps over the lazy dog
' The quick brown fox jumps over three napping cats in the barn
'
-
-'
-Public Class SamplesArray2
-
- Public Shared Sub Main()
- ' Creates and initializes the source Array.
- Dim myArrayZero As Array = Array.CreateInstance(GetType(String), 3)
- myArrayZero.SetValue("zero", 0)
- myArrayZero.SetValue("one", 1)
-
- ' Displays the source Array.
- Console.WriteLine("The array with lower bound=0 contains:")
- PrintIndexAndValues(myArrayZero)
-
- ' Creates and initializes the target Array.
- Dim myArrLen As Integer() = {4}
- Dim myArrLow As Integer() = {2}
- Dim myArrayTwo As Array = Array.CreateInstance(GetType(String), _
- myArrLen, myArrLow)
- myArrayTwo.SetValue("two", 2)
- myArrayTwo.SetValue("three", 3)
- myArrayTwo.SetValue("four", 4)
- myArrayTwo.SetValue("five", 5)
-
- ' Displays the target Array.
- Console.WriteLine("The array with lower bound=2 contains:")
- PrintIndexAndValues(myArrayTwo)
-
- ' Copies from the array with lower bound=0 to the array with lower bound=2.
- myArrayZero.CopyTo(myArrayTwo, 3)
-
- ' Displays the modified target Array.
- Console.WriteLine(ControlChars.Cr + "After copying to the target array from " _
- + "index 3:")
- PrintIndexAndValues(myArrayTwo)
- End Sub
-
- Public Shared Sub PrintIndexAndValues(myArray As Array)
- Dim i As Integer
- For i = myArray.GetLowerBound(0) To myArray.GetUpperBound(0)
- Console.WriteLine(ControlChars.Tab + "[{0}]:" + ControlChars.Tab _
- + "{1}", i, myArray.GetValue(i))
- Next i
- End Sub
-End Class
-
-' This code produces the following output.
-'
-' The array with lower bound=0 contains:
-' [0]: zero
-' [1]: one
-' [2]:
-' The array with lower bound=2 contains:
-' [2]: two
-' [3]: three
-' [4]: four
-' [5]: five
-'
-' After copying to the target array from index 3:
-' [2]: two
-' [3]: zero
-' [4]: one
-' [5]:
-'
diff --git a/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source2.vb b/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source2.vb
new file mode 100644
index 00000000000..f4f043cbb9c
--- /dev/null
+++ b/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source2.vb
@@ -0,0 +1,63 @@
+'
+Public Class SamplesArray2
+
+ Public Shared Sub Main()
+ ' Creates and initializes the source Array.
+ Dim myArrayZero As Array = Array.CreateInstance(GetType(String), 3)
+ myArrayZero.SetValue("zero", 0)
+ myArrayZero.SetValue("one", 1)
+
+ ' Displays the source Array.
+ Console.WriteLine("The array with lower bound=0 contains:")
+ PrintIndexAndValues(myArrayZero)
+
+ ' Creates and initializes the target Array.
+ Dim myArrLen As Integer() = {4}
+ Dim myArrLow As Integer() = {2}
+ Dim myArrayTwo As Array = Array.CreateInstance(GetType(String), _
+ myArrLen, myArrLow)
+ myArrayTwo.SetValue("two", 2)
+ myArrayTwo.SetValue("three", 3)
+ myArrayTwo.SetValue("four", 4)
+ myArrayTwo.SetValue("five", 5)
+
+ ' Displays the target Array.
+ Console.WriteLine("The array with lower bound=2 contains:")
+ PrintIndexAndValues(myArrayTwo)
+
+ ' Copies from the array with lower bound=0 to the array with lower bound=2.
+ myArrayZero.CopyTo(myArrayTwo, 3)
+
+ ' Displays the modified target Array.
+ Console.WriteLine(ControlChars.Cr + "After copying to the target array from " _
+ + "index 3:")
+ PrintIndexAndValues(myArrayTwo)
+ End Sub
+
+ Public Shared Sub PrintIndexAndValues(myArray As Array)
+ Dim i As Integer
+ For i = myArray.GetLowerBound(0) To myArray.GetUpperBound(0)
+ Console.WriteLine(ControlChars.Tab + "[{0}]:" + ControlChars.Tab _
+ + "{1}", i, myArray.GetValue(i))
+ Next i
+ End Sub
+End Class
+
+' This code produces the following output.
+'
+' The array with lower bound=0 contains:
+' [0]: zero
+' [1]: one
+' [2]:
+' The array with lower bound=2 contains:
+' [2]: two
+' [3]: three
+' [4]: four
+' [5]: five
+'
+' After copying to the target array from index 3:
+' [2]: two
+' [3]: zero
+' [4]: one
+' [5]:
+'
diff --git a/xml/System.Globalization/Calendar.xml b/xml/System.Globalization/Calendar.xml
index 32b40c5fb30..520917aee38 100644
--- a/xml/System.Globalization/Calendar.xml
+++ b/xml/System.Globalization/Calendar.xml
@@ -2413,10 +2413,10 @@ Only the and the varies depending on the and the used. If the specified date is the last day of the year, returns the total number of weeks in that year.
- [!code-cpp[System.Globalization.Calendar.GetWeekOfYear#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CPP/yslin_calendar_getweekofyear.cpp#1)]
- [!code-csharp[System.Globalization.Calendar.GetWeekOfYear#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CS/yslin_calendar_getweekofyear.cs#1)]
- [!code-vb[System.Globalization.Calendar.GetWeekOfYear#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/VB/yslin_calendar_getweekofyear.vb#1)]
-
+ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CPP/yslin_calendar_getweekofyear.cpp" id="Snippet1":::
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CS/yslin_calendar_getweekofyear.cs" interactive="try-dotnet" id="Snippet1":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/VB/yslin_calendar_getweekofyear.vb" id="Snippet1":::
+
]]>
diff --git a/xml/System.Globalization/NumberStyles.xml b/xml/System.Globalization/NumberStyles.xml
index 230a77b7491..5891086a183 100644
--- a/xml/System.Globalization/NumberStyles.xml
+++ b/xml/System.Globalization/NumberStyles.xml
@@ -87,10 +87,10 @@
## Examples
This example shows how to parse a string into a 32-bit integer by using various `NumberStyles` flags.
- [!code-cpp[NumberStyles#1](~/samples/snippets/cpp/VS_Snippets_CLR/NumberStyles/cpp/NumberStyles.cpp#1)]
- [!code-csharp[NumberStyles#1](~/samples/snippets/csharp/VS_Snippets_CLR/NumberStyles/CS/NumberStyles.cs#1)]
- [!code-vb[NumberStyles#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/NumberStyles/vb/numberstyles.vb#1)]
-
+ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/NumberStyles/cpp/NumberStyles.cpp" id="Snippet1":::
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/NumberStyles/CS/NumberStyles.cs" interactive="try-dotnet" id="Snippet1":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/NumberStyles/vb/numberstyles.vb" id="Snippet1":::
+
]]>
diff --git a/xml/System/Array.xml b/xml/System/Array.xml
index d9ab053cb08..0e389ef440b 100644
--- a/xml/System/Array.xml
+++ b/xml/System/Array.xml
@@ -299,10 +299,10 @@
> [!NOTE]
> The array is created with its elements in ascending sort order. The method requires the array to be sorted in ascending order.
- [!code-cpp[Classic Array.BinarySearch Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/CPP/source.cpp#1)]
- [!code-csharp[Classic Array.BinarySearch Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/CS/source.cs#1)]
- [!code-vb[Classic Array.BinarySearch Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/VB/source.vb#1)]
-
+ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/CPP/source.cpp" id="Snippet1":::
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/CS/source.cs" interactive="try-dotnet" id="Snippet1":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/VB/source.vb" id="Snippet1":::
+
]]>
@@ -716,10 +716,10 @@
The generic method overload is then used to search for two strings, one that is not in the array and one that is. The array and the return value of the method are passed to the `ShowWhere` generic method, which displays the index value if the string is found, and otherwise the elements the search string would fall between if it were in the array. The index is negative if the string is not in the array, so the `ShowWhere` method takes the bitwise complement (the ~ operator in C# and Visual C++, `Xor`-1 in Visual Basic) to obtain the index of the first element in the list that is larger than the search string.
- [!code-cpp[Array_SortSearch#1](~/samples/snippets/cpp/VS_Snippets_CLR/Array_SortSearch/cpp/source.cpp#1)]
- [!code-csharp[Array_SortSearch#1](~/samples/snippets/csharp/VS_Snippets_CLR/Array_SortSearch/cs/source.cs#1)]
- [!code-vb[Array_SortSearch#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/Array_SortSearch/vb/source.vb#1)]
-
+ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/Array_SortSearch/cpp/source.cpp" id="Snippet1":::
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/Array_SortSearch/cs/source.cs" interactive="try-dotnet" id="Snippet1":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/Array_SortSearch/vb/source.vb" id="Snippet1":::
+
]]>
@@ -830,10 +830,10 @@
The generic method overload is then used to search for two strings, one that is not in the array and one that is. The array and the return value of the method are passed to the `ShowWhere` generic method, which displays the index value if the string is found, and otherwise the elements the search string would fall between if it were in the array. The index is negative if the string is not n the array, so the `ShowWhere` method takes the bitwise complement (the ~ operator in C# and Visual C++, `Xor` -1 in Visual Basic) to obtain the index of the first element in the list that is larger than the search string.
- [!code-cpp[Array_SortSearchComparer#1](~/samples/snippets/cpp/VS_Snippets_CLR/Array_SortSearchComparer/cpp/source.cpp#1)]
- [!code-csharp[Array_SortSearchComparer#1](~/samples/snippets/csharp/VS_Snippets_CLR/Array_SortSearchComparer/cs/source.cs#1)]
- [!code-vb[Array_SortSearchComparer#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/Array_SortSearchComparer/vb/source.vb#1)]
-
+ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/Array_SortSearchComparer/cpp/source.cpp" id="Snippet1":::
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/Array_SortSearchComparer/cs/source.cs" interactive="try-dotnet" id="Snippet1":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/Array_SortSearchComparer/vb/source.vb" id="Snippet1":::
+
]]>
@@ -1946,6 +1946,24 @@
Copies all the elements of the current one-dimensional array to the specified one-dimensional array.
+
+ to another .
+
+ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp" id="Snippet1":::
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CS/source.cs" interactive="try-dotnet" id="Snippet1":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source.vb" id="Snippet1":::
+
+ The following code example shows how to copy an to another with a nonzero lower bound. Note that the entire source is copied, including empty elements that overwrite existing elements in the target .
+
+ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source2.cpp" id="Snippet1":::
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CS/source2.cs" interactive="try-dotnet" id="Snippet1":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source2.vb" id="Snippet1":::
+
+ ]]>
+
@@ -2006,22 +2024,7 @@
If this method throws an exception while copying, the state of `array` is undefined.
This method is an O(`n`) operation, where `n` is . It performs a shallow copy only.
-
-
-
-## Examples
- The following code example shows how to copy an to another .
-
- [!code-cpp[Classic Array.CopyTo Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp#1)]
- [!code-csharp[Classic Array.CopyTo Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CS/source.cs#1)]
- [!code-vb[Classic Array.CopyTo Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source.vb#1)]
-
- The following code example shows how to copy an to another with a nonzero lower bound. Note that the entire source is copied, including empty elements that overwrite existing elements in the target .
-
- [!code-cpp[Classic Array.CopyTo Example#2](~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp#2)]
- [!code-csharp[Classic Array.CopyTo Example#2](~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CS/source.cs#2)]
- [!code-vb[Classic Array.CopyTo Example#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source.vb#2)]
-
+
]]>
@@ -2102,21 +2105,6 @@
This method is an O(`n`) operation, where `n` is . It performs a shallow copy only.
-
-
-## Examples
- The following code example shows how to copy an to another .
-
- [!code-cpp[Classic Array.CopyTo Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp#1)]
- [!code-csharp[Classic Array.CopyTo Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CS/source.cs#1)]
- [!code-vb[Classic Array.CopyTo Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source.vb#1)]
-
- The following code example shows how to copy an to another with a nonzero lower bound. Note that the entire source is copied, including empty elements that overwrite existing elements in the target .
-
- [!code-cpp[Classic Array.CopyTo Example#2](~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp#2)]
- [!code-csharp[Classic Array.CopyTo Example#2](~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CS/source.cs#2)]
- [!code-vb[Classic Array.CopyTo Example#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source.vb#2)]
-
]]>
diff --git a/xml/System/DateTime.xml b/xml/System/DateTime.xml
index 0e0c23f2177..8f1bfb3ac94 100644
--- a/xml/System/DateTime.xml
+++ b/xml/System/DateTime.xml
@@ -2447,9 +2447,9 @@ The behavior of the .NET Framework and COM means that if your application round-
## Remarks
The property always returns the day of the month in the Gregorian calendar, even if the current value was instantiated using some other calendar or if the current thread culture's default calendar is not the Gregorian calendar. To retrieve the day of the month of a particular date using some other calendar, call that calendar's method. The following example uses both the property and the method to retrieve the day of the month for a value that is instantiated using the Hijri calendar.
- [!code-csharp[System.DateTime.Day#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.DateTime.Day/cs/Day1.cs#1)]
- [!code-vb[System.DateTime.Day#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Day/vb/Day1.vb#1)]
-
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.DateTime.Day/cs/Day1.cs" interactive="try-dotnet-method" id="Snippet1":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Day/vb/Day1.vb" id="Snippet1":::
+
Similarly, the following example uses both the property and the method to retrieve the day of the month when the current thread culture is ar-SA, which uses Hijri as its default calendar.
[!code-csharp[System.DateTime.Day#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.DateTime.Day/cs/Day2.cs#2)]
@@ -2462,8 +2462,8 @@ The behavior of the .NET Framework and COM means that if your application round-
[!code-cpp[System.DateTime.Minute etc#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CPP/class1.cpp#1)]
[!code-csharp[System.DateTime.Minute etc#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CS/class1.cs#1)]
- [!code-vb[System.DateTime.Minute etc#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Minute etc/VB/class1.vb#1)]
-
+ [!code-vb[System.DateTime.Minute etc#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Minute etc/VB/class1.vb#1)]
+
]]>
@@ -3820,19 +3820,19 @@ juillet 2009
## Remarks
The value of the property is always expressed using a 24-hour clock. To retrieve a string that represents the hour of a date and time using a 12-hour clock, call the or method with the "h" custom format specifier. For example:
-
- [!code-csharp[System.DateTime.Hour#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.DateTime.Hour/cs/Hour1.cs#1)]
- [!code-vb[System.DateTime.Hour#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Hour/vb/Hour1.vb#1)]
+
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.DateTime.Hour/cs/Hour1.cs" interactive="try-dotnet-method" id="Snippet1":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Hour/vb/Hour1.vb" id="Snippet1":::
## Examples
The following example demonstrates the property.
- [!code-cpp[System.DateTime.Minute etc#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CPP/class1.cpp#1)]
- [!code-csharp[System.DateTime.Minute etc#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CS/class1.cs#1)]
- [!code-vb[System.DateTime.Minute etc#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Minute etc/VB/class1.vb#1)]
-
+ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CPP/class1.cpp" id="Snippet1":::
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CS/class1.cs" id="Snippet1":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Minute etc/VB/class1.vb" id="Snippet1":::
+
]]>
diff --git a/xml/System/Enum.xml b/xml/System/Enum.xml
index 5de94e2ac56..664776b93dd 100644
--- a/xml/System/Enum.xml
+++ b/xml/System/Enum.xml
@@ -1100,9 +1100,9 @@ thisInstance And flag = flag
## Examples
The following example defines an enumeration named `PetType` that consists of individual bit fields. It then calls the method with possible underlying enumeration values, string names, and composite values that result from setting multiple bit fields.
- [!code-csharp[System.Enum.IsDefined#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Enum.IsDefined/cs/isdefined1.cs#1)]
- [!code-vb[System.Enum.IsDefined#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Enum.IsDefined/vb/IsDefined1.vb#1)]
-
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Enum.IsDefined/cs/isdefined1.cs" interactive="try-dotnet" id="Snippet1":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Enum.IsDefined/vb/IsDefined1.vb" id="Snippet1":::
+
]]>
@@ -1122,9 +1122,9 @@ thisInstance And flag = flag
If is an enumeration that is defined by using the attribute, the method returns if multiple bit fields in are set but does not correspond to a composite enumeration value, or if is a string concatenation of the names of multiple bit flags. In the following example, a Pets enumeration is defined with the attribute. The method returns when you pass it an enumeration value that has two bit fields (Pets.Dog and Pets.Cat) set, and when you pass it the string representation of that enumeration value ("Dog, Cat").
- [!code-csharp[System.Enum.IsDefined#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Enum.IsDefined/cs/isdefined2.cs#2)]
- [!code-vb[System.Enum.IsDefined#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Enum.IsDefined/vb/isdefined2.vb#2)]
-
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Enum.IsDefined/cs/isdefined2.cs" interactive="try-dotnet" id="Snippet2":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Enum.IsDefined/vb/isdefined2.vb" id="Snippet2":::
+
You can determine whether multiple bit fields are set by calling the method.
diff --git a/xml/System/InvalidCastException.xml b/xml/System/InvalidCastException.xml
index b8ae75e9f5d..e0be6f71c6a 100644
--- a/xml/System/InvalidCastException.xml
+++ b/xml/System/InvalidCastException.xml
@@ -97,8 +97,8 @@ For a list of initial property values for an instance of implementation that does not support a particular conversion. For example, trying to convert a value to a or a value to an throws an exception. The following example calls both the and methods to convert a value to a . In both cases, the method call throws an exception.
- [!code-csharp[System.InvalidCastException#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.invalidcastexception/cs/iconvertible1.cs#2)]
- [!code-vb[System.InvalidCastException#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.invalidcastexception/vb/iconvertible1.vb#2)]
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.invalidcastexception/cs/iconvertible1.cs" interactive="try-dotnet" id="Snippet2":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.invalidcastexception/vb/iconvertible1.vb" id="Snippet2":::
Because the conversion is not supported, there is no workaround.
@@ -120,8 +120,8 @@ For a list of initial property values for an instance of method is defined by the class and therefore is either inherited or overridden by all managed types.
- [!code-csharp[System.InvalidCastException#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.invalidcastexception/cs/ToString2.cs#5)]
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.invalidcastexception/cs/ToString2.cs" interactive="try-dotnet" id="Snippet5":::
## Visual Basic 6.0 migration
diff --git a/xml/System/Single.xml b/xml/System/Single.xml
index bfcad01db67..5fe4eb68575 100644
--- a/xml/System/Single.xml
+++ b/xml/System/Single.xml
@@ -110,24 +110,24 @@
|Sign (0 = positive, 1 = negative)|31|
Just as decimal fractions are unable to precisely represent some fractional values (such as 1/3 or ), binary fractions are unable to represent some fractional values. For example, 2/10, which is represented precisely by .2 as a decimal fraction, is represented by .0011111001001100 as a binary fraction, with the pattern "1100" repeating to infinity. In this case, the floating-point value provides an imprecise representation of the number that it represents. Performing additional mathematical operations on the original floating-point value often increases its lack of precision. For example, if you compare the results of multiplying .3 by 10 and adding .3 to .3 nine times, you will see that addition produces the less precise result, because it involves eight more operations than multiplication. Note that this disparity is apparent only if you display the two values by using the "R" [standard numeric format string](/dotnet/standard/base-types/standard-numeric-format-strings), which, if necessary, displays all 9 digits of precision supported by the type.
-
- [!code-csharp[System.Single.Structure#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/representation1.cs#3)]
- [!code-vb[System.Single.Structure#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/representation1.vb#3)]
-
+
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/representation1.cs" interactive="try-dotnet" id="Snippet3":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/representation1.vb" id="Snippet3":::
+
Because some numbers cannot be represented exactly as fractional binary values, floating-point numbers can only approximate real numbers.
All floating-point numbers have a limited number of significant digits, which also determines how accurately a floating-point value approximates a real number. A value has up to 7 decimal digits of precision, although a maximum of 9 digits is maintained internally. This means that some floating-point operations may lack the precision to change a floating-point value. The following example defines a large single-precision floating-point value, and then adds the product of and one quadrillion to it. However, the product is too small to modify the original floating-point value. Its least significant digit is thousandths, whereas the most significant digit in the product is 10-30.
- [!code-csharp[System.Single.Structure#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/representation2.cs#4)]
- [!code-vb[System.Single.Structure#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/representation2.vb#4)]
-
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/representation2.cs" interactive="try-dotnet" id="Snippet4":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/representation2.vb" id="Snippet4":::
+
The limited precision of a floating-point number has several consequences:
- Two floating-point numbers that appear equal for a particular precision might not compare equal because their least significant digits are different. In the following example, a series of numbers are added together, and their total is compared with their expected total. Although the two values appear to be the same, a call to the `Equals` method indicates that they are not.
- [!code-csharp[System.Single.Structure#6](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/precisionlist3.cs#6)]
- [!code-vb[System.Single.Structure#6](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/precisionlist3.vb#6)]
-
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/precisionlist3.cs" interactive="try-dotnet" id="Snippet6":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/precisionlist3.vb" id="Snippet6":::
+
If you change the format items in the statement from `{0}` and `{1}` to `{0:R}` and `{1:R}` to display all significant digits of the two values, it is clear that the two values are unequal because of a loss of precision during the addition operations. In this case, the issue can be resolved by calling the method to round the values to the desired precision before performing the comparison.
- A mathematical or comparison operation that uses a floating-point number might not yield the same result if a decimal number is used, because the binary floating-point number might not equal the decimal number. A previous example illustrated this by displaying the result of multiplying .3 by 10 and adding .3 to .3 nine times.
@@ -146,30 +146,30 @@
- values have less precision than values. A value that is converted to a seemingly equivalent often does not equal the value because of differences in precision. In the following example, the result of identical division operations is assigned to a value and a value. After the value is cast to a , a comparison of the two values shows that they are unequal.
- [!code-csharp[System.Double.Structure#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.double.structure/cs/precisionlist1.cs#5)]
- [!code-vb[System.Double.Structure#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.double.structure/vb/precisionlist1.vb#5)]
-
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.double.structure/cs/precisionlist1.cs" interactive="try-dotnet" id="Snippet5":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.double.structure/vb/precisionlist1.vb" id="Snippet5":::
+
To avoid this problem, either use the data type in place of the data type, or use the method so that both values have the same precision.
## Testing for equality
To be considered equal, two values must represent identical values. However, because of differences in precision between values, or because of a loss of precision by one or both values, floating-point values that are expected to be identical often turn out to be unequal due to differences in their least significant digits. As a result, calls to the method to determine whether two values are equal, or calls to the method to determine the relationship between two values, often yield unexpected results. This is evident in the following example, where two apparently equal values turn out to be unequal, because the first value has 7 digits of precision, whereas the second value has 9.
- [!code-csharp[System.Single.Structure#9](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/comparison1.cs#9)]
- [!code-vb[System.Single.Structure#9](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/comparison1.vb#9)]
-
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/comparison1.cs" interactive="try-dotnet" id="Snippet9":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/comparison1.vb" id="Snippet9":::
+
Calculated values that follow different code paths and that are manipulated in different ways often prove to be unequal. In the following example, one value is squared, and then the square root is calculated to restore the original value. A second is multiplied by 3.51 and squared before the square root of the result is divided by 3.51 to restore the original value. Although the two values appear to be identical, a call to the method indicates that they are not equal. Using the "G9" standard format string to return a result string that displays all the significant digits of each value shows that the second value is .0000000000001 less than the first.
- [!code-csharp[System.Single.Structure#10](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/comparison2.cs#10)]
- [!code-vb[System.Single.Structure#10](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/comparison2.vb#10)]
-
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/comparison2.cs" interactive="try-dotnet" id="Snippet10":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/comparison2.vb" id="Snippet10":::
+
In cases where a loss of precision is likely to affect the result of a comparison, you can use the following techniques instead of calling the or method:
- Call the method to ensure that both values have the same precision. The following example modifies a previous example to use this approach so that two fractional values are equivalent.
- [!code-csharp[System.Single.Structure#11](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/comparison3.cs#11)]
- [!code-vb[System.Single.Structure#11](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/comparison3.vb#11)]
-
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/comparison3.cs" interactive="try-dotnet" id="Snippet11":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/comparison3.vb" id="Snippet11":::
+
Note that the problem of precision still applies to rounding of midpoint values. For more information, see the method.
- Test for approximate equality instead of equality. This technique requires that you define either an absolute amount by which the two values can differ but still be equal, or that you define a relative amount by which the smaller value can diverge from the larger value.
@@ -179,23 +179,23 @@
The following example uses the latter approach to define an `IsApproximatelyEqual` method that tests the relative difference between two values. It also contrasts the result of calls to the `IsApproximatelyEqual` method and the method.
- [!code-csharp[System.Single.Structure#12](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/comparison4.cs#12)]
- [!code-vb[System.Single.Structure#12](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/comparison4.vb#12)]
-
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/comparison4.cs" interactive="try-dotnet" id="Snippet12":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/comparison4.vb" id="Snippet12":::
+
## Floating-point values and exceptions
Operations with floating-point values do not throw exceptions, unlike operations with integral types, which throw exceptions in cases of illegal operations such as division by zero or overflow. Instead, in these situations, the result of a floating-point operation is zero, positive infinity, negative infinity, or not a number (NaN):
- If the result of a floating-point operation is too small for the destination format, the result is zero. This can occur when two very small floating-point numbers are multiplied, as the following example shows.
- [!code-csharp[System.Single.Structure#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/exceptional1.cs#1)]
- [!code-vb[System.Single.Structure#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/exceptional1.vb#1)]
-
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/exceptional1.cs" interactive="try-dotnet" id="Snippet1":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/exceptional1.vb" id="Snippet1":::
+
- If the magnitude of the result of a floating-point operation exceeds the range of the destination format, the result of the operation is or , as appropriate for the sign of the result. The result of an operation that overflows is , and the result of an operation that overflows is , as the following example shows.
- [!code-csharp[System.Single.Structure#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/exceptional2.cs#2)]
- [!code-vb[System.Single.Structure#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/exceptional2.vb#2)]
-
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/exceptional2.cs" interactive="try-dotnet" id="Snippet2":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/exceptional2.vb" id="Snippet2":::
+
also results from a division by zero with a positive dividend, and results from a division by zero with a negative dividend.
- If a floating-point operation is invalid, the result of the operation is . For example, results from the following operations:
@@ -292,9 +292,9 @@
The problem of precision most frequently affects values that are converted to values. In the following example, two values produced by identical division operations are unequal, because one of the values is a single-precision floating point value that is converted to a .
- [!code-csharp[System.Single.Structure#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/precisionlist1.cs#5)]
- [!code-vb[System.Single.Structure#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/precisionlist1.vb#5)]
-
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.single.structure/cs/precisionlist1.cs" interactive="try-dotnet" id="Snippet5":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.single.structure/vb/precisionlist1.vb" id="Snippet5":::
+
]]>
All members of this type are thread safe. Members that appear to modify instance state actually return a new instance initialized with the new value. As with any other type, reading and writing to a shared variable that contains an instance of this type must be protected by a lock to guarantee thread safety.
diff --git a/xml/System/UriBuilder.xml b/xml/System/UriBuilder.xml
index e975f9b12f9..c8244e2df4a 100644
--- a/xml/System/UriBuilder.xml
+++ b/xml/System/UriBuilder.xml
@@ -624,10 +624,10 @@
## Examples
The following example creates the URI `"http://www.contoso.com/index.htm#main"`.
- [!code-cpp[Classic UriBuilder.Fragment Example#1](~/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/CPP/source.cpp#1)]
- [!code-csharp[Classic UriBuilder.Fragment Example#1](~/samples/snippets/csharp/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/CS/source.cs#1)]
- [!code-vb[Classic UriBuilder.Fragment Example#1](~/samples/snippets/visualbasic/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/VB/source.vb#1)]
-
+ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/CPP/source.cpp" id="Snippet1":::
+ :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/CS/source.cs" id="Snippet1":::
+ :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/VB/source.vb" id="Snippet1":::
+
]]>