diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp index 68ba21f61c8..79d6693b5c4 100644 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp +++ b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp @@ -20,4 +20,6 @@ int main() Console::WriteLine( "\t namespaceURI={0}", elem->NamespaceURI ); } +// This code produces the following output. +// bk:ISBN = 1-861001-57-5 namespaceURI=urn:samples // diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Name Example/CPP/source.cpp index b658efb2434..0523cdebda0 100644 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Name Example/CPP/source.cpp +++ b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Name Example/CPP/source.cpp @@ -20,4 +20,6 @@ int main() Console::WriteLine( "\t namespaceURI={0}", elem->NamespaceURI ); } +// This code produces the following output. +// bk:ISBN = 1-861001-57-5 namespaceURI=urn:samples // diff --git a/snippets/cpp/VS_Snippets_Winforms/Application/CPP/source.cpp b/snippets/cpp/VS_Snippets_Winforms/Application/CPP/source.cpp index bf2c74e7f1b..8e199bdfb3a 100644 --- a/snippets/cpp/VS_Snippets_Winforms/Application/CPP/source.cpp +++ b/snippets/cpp/VS_Snippets_Winforms/Application/CPP/source.cpp @@ -1,5 +1,3 @@ - - // #using #using @@ -24,7 +22,6 @@ public ref class AppForm2: public System::Windows::Forms::Form }; - // A simple form that represents a window in our application public ref class AppForm1: public System::Windows::Forms::Form { @@ -37,25 +34,24 @@ public ref class AppForm1: public System::Windows::Forms::Form }; - // // The class that handles the creation of the application windows ref class MyApplicationContext: public ApplicationContext { private: - int formCount; - AppForm1^ form1; - AppForm2^ form2; - System::Drawing::Rectangle form1Position; - System::Drawing::Rectangle form2Position; - FileStream^ userData; + int _formCount; + AppForm1^ _form1; + AppForm2^ _form2; + System::Drawing::Rectangle _form1Position; + System::Drawing::Rectangle _form2Position; + FileStream^ _userData; public: // MyApplicationContext() { - formCount = 0; + _formCount = 0; // Handle the ApplicationExit event to know when the application is exiting. Application::ApplicationExit += gcnew EventHandler( this, &MyApplicationContext::OnApplicationExit ); @@ -63,7 +59,7 @@ ref class MyApplicationContext: public ApplicationContext { // Create a file that the application will store user specific data in. - userData = gcnew FileStream( String::Concat( Application::UserAppDataPath, "\\appdata.txt" ),FileMode::OpenOrCreate ); + _userData = gcnew FileStream( String::Concat( Application::UserAppDataPath, "\\appdata.txt" ),FileMode::OpenOrCreate ); } catch ( IOException^ e ) { @@ -78,14 +74,14 @@ ref class MyApplicationContext: public ApplicationContext // Create both application forms and handle the Closed event // to know when both forms are closed. - form1 = gcnew AppForm1; - form1->Closed += gcnew EventHandler( this, &MyApplicationContext::OnFormClosed ); - form1->Closing += gcnew CancelEventHandler( this, &MyApplicationContext::OnFormClosing ); - formCount++; - form2 = gcnew AppForm2; - form2->Closed += gcnew EventHandler( this, &MyApplicationContext::OnFormClosed ); - form2->Closing += gcnew CancelEventHandler( this, &MyApplicationContext::OnFormClosing ); - formCount++; + _form1 = gcnew AppForm1; + _form1->Closed += gcnew EventHandler( this, &MyApplicationContext::OnFormClosed ); + _form1->Closing += gcnew CancelEventHandler( this, &MyApplicationContext::OnFormClosing ); + _formCount++; + _form2 = gcnew AppForm2; + _form2->Closed += gcnew EventHandler( this, &MyApplicationContext::OnFormClosed ); + _form2->Closing += gcnew CancelEventHandler( this, &MyApplicationContext::OnFormClosing ); + _formCount++; // Get the form positions based upon the user specific data. if ( ReadFormDataFromFile() ) @@ -93,16 +89,16 @@ ref class MyApplicationContext: public ApplicationContext // If the data was read from the file, set the form // positions manually. - form1->StartPosition = FormStartPosition::Manual; - form2->StartPosition = FormStartPosition::Manual; - form1->Bounds = form1Position; - form2->Bounds = form2Position; + _form1->StartPosition = FormStartPosition::Manual; + _form2->StartPosition = FormStartPosition::Manual; + _form1->Bounds = _form1Position; + _form2->Bounds = _form2Position; } // Show both forms. - form1->Show(); - form2->Show(); + _form1->Show(); + _form2->Show(); } void OnApplicationExit( Object^ /*sender*/, EventArgs^ /*e*/ ) @@ -115,7 +111,7 @@ ref class MyApplicationContext: public ApplicationContext { // Ignore any errors that might occur while closing the file handle. - userData->Close(); + _userData->Close(); } catch ( Exception^ ) { @@ -123,7 +119,6 @@ ref class MyApplicationContext: public ApplicationContext } - private: // @@ -133,13 +128,12 @@ ref class MyApplicationContext: public ApplicationContext // When a form is closing, remember the form position so it // can be saved in the user data file. if ( dynamic_cast(sender) != nullptr ) - form1Position = (dynamic_cast(sender))->Bounds; + _form1Position = (dynamic_cast(sender))->Bounds; else if ( dynamic_cast(sender) != nullptr ) - form2Position = (dynamic_cast(sender))->Bounds; + _form2Position = (dynamic_cast(sender))->Bounds; } - // void OnFormClosed( Object^ /*sender*/, EventArgs^ /*e*/ ) { @@ -147,14 +141,13 @@ ref class MyApplicationContext: public ApplicationContext // When a form is closed, decrement the count of open forms. // When the count gets to 0, exit the app by calling // ExitThread(). - formCount--; - if ( formCount == 0 ) + _formCount--; + if ( _formCount == 0 ) { ExitThread(); } } - // bool WriteFormDataToFile() { @@ -162,17 +155,17 @@ ref class MyApplicationContext: public ApplicationContext // Write the form positions to the file. UTF8Encoding^ encoding = gcnew UTF8Encoding; RectangleConverter^ rectConv = gcnew RectangleConverter; - String^ form1pos = rectConv->ConvertToString( form1Position ); - String^ form2pos = rectConv->ConvertToString( form2Position ); + String^ form1pos = rectConv->ConvertToString( _form1Position ); + String^ form2pos = rectConv->ConvertToString( _form2Position ); array^dataToWrite = encoding->GetBytes( String::Concat( "~", form1pos, "~", form2pos ) ); try { // Set the write position to the start of the file and write - userData->Seek( 0, SeekOrigin::Begin ); - userData->Write( dataToWrite, 0, dataToWrite->Length ); - userData->Flush(); - userData->SetLength( dataToWrite->Length ); + _userData->Seek( 0, SeekOrigin::Begin ); + _userData->Write( dataToWrite, 0, dataToWrite->Length ); + _userData->Flush(); + _userData->SetLength( dataToWrite->Length ); return true; } catch ( Exception^ ) @@ -190,15 +183,15 @@ ref class MyApplicationContext: public ApplicationContext // Read the form positions from the file. UTF8Encoding^ encoding = gcnew UTF8Encoding; String^ data; - if ( userData->Length != 0 ) + if ( _userData->Length != 0 ) { - array^dataToRead = gcnew array(userData->Length); + array^dataToRead = gcnew array(_userData->Length); try { // Set the read position to the start of the file and read. - userData->Seek( 0, SeekOrigin::Begin ); - userData->Read( dataToRead, 0, dataToRead->Length ); + _userData->Seek( 0, SeekOrigin::Begin ); + _userData->Read( dataToRead, 0, dataToRead->Length ); } catch ( IOException^ e ) { @@ -207,7 +200,6 @@ ref class MyApplicationContext: public ApplicationContext // An error occurred while attempt to read, return false. return false; } - // Parse out the data to get the window rectangles data = encoding->GetString( dataToRead ); @@ -217,9 +209,9 @@ ref class MyApplicationContext: public ApplicationContext // Convert the String* data to rectangles RectangleConverter^ rectConv = gcnew RectangleConverter; String^ form1pos = data->Substring( 1, data->IndexOf( "~", 1 ) - 1 ); - form1Position = *safe_cast(rectConv->ConvertFromString( form1pos )); + _form1Position = *safe_cast(rectConv->ConvertFromString( form1pos )); String^ form2pos = data->Substring( data->IndexOf( "~", 1 ) + 1 ); - form2Position = *safe_cast(rectConv->ConvertFromString( form2pos )); + _form2Position = *safe_cast(rectConv->ConvertFromString( form2pos )); return true; } catch ( Exception^ ) @@ -229,7 +221,6 @@ ref class MyApplicationContext: public ApplicationContext // Return false to use default values. return false; } - } else { @@ -238,13 +229,10 @@ ref class MyApplicationContext: public ApplicationContext return false; } } - }; - - // -// +// [STAThread] int main() { @@ -257,6 +245,5 @@ int main() // all forms are closed. Application::Run( context ); } - // -// +// \ No newline at end of file diff --git a/snippets/csharp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CS/source.cs b/snippets/csharp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CS/source.cs index b5805537efa..96d8fba2946 100644 --- a/snippets/csharp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CS/source.cs @@ -18,8 +18,10 @@ public static void Main() XmlElement elem = (XmlElement) doc.DocumentElement.FirstChild; Console.Write("{0}:{1} = {2}", elem.Prefix, elem.LocalName, elem.InnerText); Console.WriteLine("\t namespaceURI=" + elem.NamespaceURI); - } } + +// This code produces the following output. +// bk:ISBN = 1-861001-57-5 namespaceURI=urn:samples // diff --git a/snippets/csharp/VS_Snippets_Data/Classic WebData XmlElement.Name Example/CS/source.cs b/snippets/csharp/VS_Snippets_Data/Classic WebData XmlElement.Name Example/CS/source.cs index 514a687c8b8..7f17ffdeadd 100644 --- a/snippets/csharp/VS_Snippets_Data/Classic WebData XmlElement.Name Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_Data/Classic WebData XmlElement.Name Example/CS/source.cs @@ -18,8 +18,10 @@ public static void Main() XmlElement elem = (XmlElement) doc.DocumentElement.FirstChild; Console.Write("{0} = {1}", elem.Name, elem.InnerText); Console.WriteLine("\t namespaceURI=" + elem.NamespaceURI); - } } + +// This code produces the following output. +// bk:ISBN = 1-861001-57-5 namespaceURI=urn:samples // diff --git a/snippets/csharp/api/system/span/slice2/Program.cs b/snippets/csharp/api/system/span/slice2/Program.cs index 31b63cfbec0..9b7518cc337 100644 --- a/snippets/csharp/api/system/span/slice2/Program.cs +++ b/snippets/csharp/api/system/span/slice2/Program.cs @@ -12,7 +12,7 @@ static void Main() private static int GetContentLength(ReadOnlySpan span) { var slice = span.Slice(16); - return Int32.Parse(slice); + return Int32.Parse(slice); } } // Output: diff --git a/snippets/csharp/language-reference/operators/GreaterAndLessOperatorsExamples.cs b/snippets/csharp/language-reference/operators/GreaterAndLessOperatorsExamples.cs index 4c7171dce5e..ed706dfd053 100644 --- a/snippets/csharp/language-reference/operators/GreaterAndLessOperatorsExamples.cs +++ b/snippets/csharp/language-reference/operators/GreaterAndLessOperatorsExamples.cs @@ -22,6 +22,9 @@ private static void Greater() Console.WriteLine(7.0 > 5.1); // output: True Console.WriteLine(5.1 > 5.1); // output: False Console.WriteLine(0.0 > 5.1); // output: False + + Console.WriteLine(double.NaN > 5.1); // output: False + Console.WriteLine(double.NaN <= 5.1); // output: False // } @@ -31,6 +34,9 @@ private static void Less() Console.WriteLine(7.0 < 5.1); // output: False Console.WriteLine(5.1 < 5.1); // output: False Console.WriteLine(0.0 < 5.1); // output: True + + Console.WriteLine(double.NaN < 5.1); // output: False + Console.WriteLine(double.NaN >= 5.1); // output: False // } @@ -40,6 +46,9 @@ private static void GreaterOrEqual() Console.WriteLine(7.0 >= 5.1); // output: True Console.WriteLine(5.1 >= 5.1); // output: True Console.WriteLine(0.0 >= 5.1); // output: False + + Console.WriteLine(double.NaN < 5.1); // output: False + Console.WriteLine(double.NaN >= 5.1); // output: False // } @@ -49,6 +58,9 @@ private static void LessOrEqual() Console.WriteLine(7.0 <= 5.1); // output: False Console.WriteLine(5.1 <= 5.1); // output: True Console.WriteLine(0.0 <= 5.1); // output: True + + Console.WriteLine(double.NaN > 5.1); // output: False + Console.WriteLine(double.NaN <= 5.1); // output: False // } } diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb index e6a71b725a1..8165333f8e3 100644 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb +++ b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb @@ -18,8 +18,10 @@ public class Sample elem = CType(doc.DocumentElement.ChildNodes.Item(0),XmlElement) Console.Write("{0}:{1} = {2}", elem.Prefix, elem.LocalName, elem.InnerText) Console.WriteLine(" namespaceURI=" + elem.NamespaceURI) - end sub end class + +' This code produces the following output. +' bk:ISBN = 1-861001-57-5 namespaceURI=urn:samples ' diff --git a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.Name Example/VB/source.vb b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.Name Example/VB/source.vb index 18043fcd546..149afbe6b9a 100644 --- a/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.Name Example/VB/source.vb +++ b/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.Name Example/VB/source.vb @@ -18,8 +18,10 @@ public class Sample elem = CType(doc.DocumentElement.ChildNodes.Item(0),XmlElement) Console.Write("{0} = {1}", elem.Name, elem.InnerText) Console.WriteLine(" namespaceURI=" + elem.NamespaceURI) - end sub end class + +' This code produces the following output. +' bk:ISBN = 1-861001-57-5 namespaceURI=urn:samples ' diff --git a/snippets/visualbasic/VS_Snippets_Winforms/Application/VB/source.vb b/snippets/visualbasic/VS_Snippets_Winforms/Application/VB/source.vb index c86c8558b3a..374fd6629b1 100644 --- a/snippets/visualbasic/VS_Snippets_Winforms/Application/VB/source.vb +++ b/snippets/visualbasic/VS_Snippets_Winforms/Application/VB/source.vb @@ -39,30 +39,30 @@ End Class Public Class MyApplicationContext Inherits ApplicationContext - Private formCount As Integer - Private form1 As AppForm1 - Private form2 As AppForm2 + Private _formCount As Integer + Private _form1 As AppForm1 + Private _form2 As AppForm2 - Private form1Position As Rectangle - Private form2Position As Rectangle + Private _form1Position As Rectangle + Private _form2Position As Rectangle - Private userData As FileStream + Private _userData As FileStream ' Public Sub New() MyBase.New() - formCount = 0 + _formCount = 0 ' Handle the ApplicationExit event to know when the application is exiting. AddHandler Application.ApplicationExit, AddressOf OnApplicationExit Try ' Create a file that the application will store user specific data in. - userData = New FileStream(Application.UserAppDataPath + "\appdata.txt", FileMode.OpenOrCreate) + _userData = New FileStream(Application.UserAppDataPath + "\appdata.txt", FileMode.OpenOrCreate) Catch e As IOException ' Inform the user that an error occurred. - MessageBox.Show("An error occurred while attempting to show the application." + _ + MessageBox.Show("An error occurred while attempting to show the application." + "The error is:" + e.ToString()) ' Exit the current thread instead of showing the windows. @@ -71,30 +71,30 @@ Public Class MyApplicationContext ' Create both application forms and handle the Closed event ' to know when both forms are closed. - form1 = New AppForm1() - AddHandler form1.Closed, AddressOf OnFormClosed - AddHandler form1.Closing, AddressOf OnFormClosing - formCount = formCount + 1 + _form1 = New AppForm1() + AddHandler _form1.Closed, AddressOf OnFormClosed + AddHandler _form1.Closing, AddressOf OnFormClosing + _formCount = _formCount + 1 - form2 = New AppForm2() - AddHandler form2.Closed, AddressOf OnFormClosed - AddHandler form2.Closing, AddressOf OnFormClosing - formCount = formCount + 1 + _form2 = New AppForm2() + AddHandler _form2.Closed, AddressOf OnFormClosed + AddHandler _form2.Closing, AddressOf OnFormClosing + _formCount = _formCount + 1 ' Get the form positions based upon the user specific data. If (ReadFormDataFromFile()) Then ' If the data was read from the file, set the form ' positions manually. - form1.StartPosition = FormStartPosition.Manual - form2.StartPosition = FormStartPosition.Manual + _form1.StartPosition = FormStartPosition.Manual + _form2.StartPosition = FormStartPosition.Manual - form1.Bounds = form1Position - form2.Bounds = form2Position + _form1.Bounds = _form1Position + _form2.Bounds = _form2Position End If ' Show both forms. - form1.Show() - form2.Show() + _form1.Show() + _form2.Show() End Sub Private Sub OnApplicationExit(ByVal sender As Object, ByVal e As EventArgs) @@ -104,7 +104,7 @@ Public Class MyApplicationContext Try ' Ignore any errors that might occur while closing the file handle. - userData.Close() + _userData.Close() Catch End Try End Sub @@ -114,20 +114,20 @@ Public Class MyApplicationContext ' When a form is closing, remember the form position so it ' can be saved in the user data file. If TypeOf sender Is AppForm1 Then - form1Position = CType(sender, Form).Bounds + _form1Position = CType(sender, Form).Bounds ElseIf TypeOf sender Is AppForm2 Then - form2Position = CType(sender, Form).Bounds + _form2Position = CType(sender, Form).Bounds End If End Sub - + ' Private Sub OnFormClosed(ByVal sender As Object, ByVal e As EventArgs) ' When a form is closed, decrement the count of open forms. ' When the count gets to 0, exit the app by calling ' ExitThread(). - formCount = formCount - 1 - If (formCount = 0) Then + _formCount = _formCount - 1 + If (_formCount = 0) Then ExitThread() End If End Sub @@ -138,18 +138,18 @@ Public Class MyApplicationContext Dim encoding As UTF8Encoding = New UTF8Encoding() Dim rectConv As RectangleConverter = New RectangleConverter() - Dim form1pos As String = rectConv.ConvertToString(form1Position) - Dim form2pos As String = rectConv.ConvertToString(form2Position) + Dim form1pos As String = rectConv.ConvertToString(_form1Position) + Dim form2pos As String = rectConv.ConvertToString(_form2Position) Dim dataToWrite As Byte() = encoding.GetBytes("~" + form1pos + "~" + form2pos) Try ' Set the write position to the start of the file and write - userData.Seek(0, SeekOrigin.Begin) - userData.Write(dataToWrite, 0, dataToWrite.Length) - userData.Flush() + _userData.Seek(0, SeekOrigin.Begin) + _userData.Write(dataToWrite, 0, dataToWrite.Length) + _userData.Flush() - userData.SetLength(dataToWrite.Length) + _userData.SetLength(dataToWrite.Length) Return True Catch @@ -164,13 +164,13 @@ Public Class MyApplicationContext Dim encoding As UTF8Encoding = New UTF8Encoding() Dim data As String - If (userData.Length <> 0) Then - Dim dataToRead(userData.Length) As Byte + If (_userData.Length <> 0) Then + Dim dataToRead(_userData.Length) As Byte Try ' Set the read position to the start of the file and read. - userData.Seek(0, SeekOrigin.Begin) - userData.Read(dataToRead, 0, dataToRead.Length) + _userData.Seek(0, SeekOrigin.Begin) + _userData.Read(dataToRead, 0, dataToRead.Length) Catch e As IOException Dim errorInfo As String = e.ToString() @@ -186,10 +186,10 @@ Public Class MyApplicationContext Dim rectConv As RectangleConverter = New RectangleConverter() Dim form1pos As String = data.Substring(1, data.IndexOf("~", 1) - 1) - form1Position = CType(rectConv.ConvertFromString(form1pos), Rectangle) + _form1Position = CType(rectConv.ConvertFromString(form1pos), Rectangle) Dim form2pos As String = data.Substring(data.IndexOf("~", 1) + 1) - form2Position = CType(rectConv.ConvertFromString(form2pos), Rectangle) + _form2Position = CType(rectConv.ConvertFromString(form2pos), Rectangle) Return True @@ -222,5 +222,4 @@ Public Module MyApplication End Module ' ' -' - +' \ No newline at end of file